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 +4 -4
- data/lib/state/workflow_instance.rb +45 -2
- data/persistence-providers.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb4b1e1715f9e1ed7b1174ff99a9adc00a13c5c0f56be3ed0d974b394fcf166d
|
4
|
+
data.tar.gz: ec5385e7dea1fac44d2c9d21ef902829a4fdee986d76a9f565ec3d6043d26f3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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
|
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|
|