persistence-providers 0.0.3.6 → 0.0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a18d9fbe5a1507dfde899dc0bf467a6148ae7bda7ed58995854ecc372ef4efa5
4
- data.tar.gz: 32cf0fa8b1433d55c7f79da8767ed7de1b8d1daa66f8c1e409d6b8978914c938
3
+ metadata.gz: bb4b1e1715f9e1ed7b1174ff99a9adc00a13c5c0f56be3ed0d974b394fcf166d
4
+ data.tar.gz: ec5385e7dea1fac44d2c9d21ef902829a4fdee986d76a9f565ec3d6043d26f3d
5
5
  SHA512:
6
- metadata.gz: bebb1b072b268c17fff5e2430e37b4fa8dd771cbbdb10930d3e7cf852c008d1d4d49c5f30a5fcce8afa9930da6e06707c9c7bfe3d58f12c13c2101ecf55ec15a
7
- data.tar.gz: 05126ad2c6f92ab855877e71929cf00f6955e21873b6782a9805c05884ec6e0e08ad53bdb7314589039acef82b96abf8bf376557252314aacefda8359c3c4070
6
+ metadata.gz: 26dcc9ac221ec5be80eb8114c50ba82d67dfaec44c809dc2435d1bb062d23de6d6faf80e2f4ff1130ad7db8ed4a7d318edd1e220340fe0fda17fd89186089868
7
+ data.tar.gz: 96207adcb7b8914850b27e6bc3e991221b1180354eb512df0db8595695cb998824f20be0c3ea86fef8ed00a1f8dfcd7fdc38bc506037a5194525a6ae4fcfd03b
@@ -26,13 +26,56 @@ module DTK::State
26
26
 
27
27
  def self.get_action_attributes(namespace, name, action_id, opts = {})
28
28
  workflow_instance = get(namespace, name, opts)
29
- action = workflow_instance.find_action(action_id)
29
+ action = WorkflowInstance.find_action(action_id, workflow_instance.workflow)
30
30
  return nil unless action
31
31
  attributes = action[:attributes] || {}
32
32
  attributes.to_h
33
33
  end
34
34
 
35
- def find_action(id, workflow = @workflow)
35
+ def self.update_action_level_result_attributes(namespace, name, attributes, action_id, opts = {})
36
+ return "Dynamic attributes do not exist for action with id #{@action_id}, nothing to update" if attributes.nil? || attributes.empty?
37
+ attributes.delete_if { |key, value| value.nil? || value.to_s.strip == '' }
38
+ workflow_instance = ::DTK::CrdClient.get_kubeclient(opts).get_workflow_instance(name, namespace)
39
+ workflow = workflow_instance[:spec][:workflow]
40
+
41
+ action = WorkflowInstance.find_action(action_id, workflow)
42
+ action[:attributes] = {} if !action[:attributes]
43
+ attributes.each do |attr_name, attr_val|
44
+ action[:attributes][attr_name.to_sym] = {} unless action[:attributes][attr_name.to_sym]
45
+ unless action[:attributes][attr_name.to_sym][:hidden]
46
+ if attr_val.is_a? Hash
47
+ action[:attributes][attr_name.to_sym][:value] = attr_val[:value] || attr_val
48
+ else
49
+ action[:attributes][attr_name.to_sym][:value] = attr_val
50
+ end
51
+ end
52
+ end
53
+ ::DTK::CrdClient.get_kubeclient(opts).update_workflow_instance(workflow_instance)
54
+ end
55
+
56
+ def self.patchError!(patches, message, action_index_steps)
57
+ errorPatch = {
58
+ "op" => "add",
59
+ "path" => "/spec/status/steps/#{action_index_steps}/errorMsg",
60
+ "value" => message
61
+ }
62
+ patches << errorPatch
63
+ end
64
+
65
+ def self.update_action_status(namespace, name, parent_id, action_id, status, error_message = "", opts = {})
66
+ workflow_instance = ::DTK::CrdClient.get_kubeclient(opts).get_workflow_instance(name, namespace)
67
+ steps = workflow_instance[:spec][:status][:steps]
68
+ action_index_steps = steps.find_index { |action| action[:id].eql? action_id }
69
+ patch = [{
70
+ "op" => "replace",
71
+ "path" => "/spec/status/steps/#{action_index_steps}/state",
72
+ "value" => status
73
+ }]
74
+ patchError!(patch, error_message, action_index_steps) unless error_message.empty? || error_message.nil?
75
+ ::DTK::CrdClient.get_kubeclient(opts).json_patch_workflow_instance(name, patch, namespace)
76
+ end
77
+
78
+ def self.find_action(id, workflow = @workflow)
36
79
  action = nil
37
80
  subtasks = workflow[:subtasks]
38
81
  subtasks.each do |subtask|
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'persistence-providers'
3
- spec.version = '0.0.3.6'
3
+ spec.version = '0.0.3.7'
4
4
  spec.author = 'Reactor8'
5
5
  spec.email = 'support@reactor8.com'
6
6
  spec.description = %q{Persistence providers plugin}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persistence-providers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.6
4
+ version: 0.0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reactor8