dtk_crd_parser 0.0.43 → 0.0.44
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/crd_parser/action/executable_action.rb +40 -0
- data/lib/crd_parser/action.rb +16 -7
- data/lib/crd_parser/component_def.rb +6 -2
- data/lib/crd_parser.rb +3 -8
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbb23a6509a68409dfa65e2f1b3be3ec1398d9eb52bf140dba8351741728e9e5
|
4
|
+
data.tar.gz: 480c95c6f9db91bc00774c1176798e51b2cb3aaf7d367391df5632e8507209e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84d24834a49e1e716e12b9210c53b4b9172f3ebe606005636e12b7b80d7c0eafd376e5f22cf8c56d321e91a8ec81558458475ad9ec81974277c8eea9a2f8d52b
|
7
|
+
data.tar.gz: 56edb7a125fdf3c5c8ddeb882c664c26ffd49d74b3f23e138d394241cb1c1262d97065e4345ef3542551e9f854b8b04b4b8969fd3f1c202ade998919ce7c43c5
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module DTK::CrdParser
|
2
|
+
class ExecutableAction < BaseClass
|
3
|
+
|
4
|
+
def initialize(name, id, component)
|
5
|
+
@name = name #action name, for example: create node group members
|
6
|
+
@component = component #this will point to the corresponding component object, example: ec2::node-group[ng]
|
7
|
+
@id = id #action subtask id
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.create_from_kube(client, component_instance, action_instance)
|
11
|
+
action_obj = client.get_action(action_instance[:name], action_instance[:namespace])
|
12
|
+
@actionExists = false
|
13
|
+
action = find_action(action_instance[:id], action_obj[:spec][:action])
|
14
|
+
component_name = action[:component]
|
15
|
+
component = Component.create_from_kube(client, component_instance, component_name)
|
16
|
+
Action.new(action[:name], action[:id], component)
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
@action = nil
|
22
|
+
@actionExists = false
|
23
|
+
def self.find_action(id, actionObject)
|
24
|
+
return @action if @actionExists
|
25
|
+
iterator = 0
|
26
|
+
while (!@actionExists && iterator < actionObject[:subtasks].length)
|
27
|
+
@action = actionObject[:subtasks][iterator]
|
28
|
+
if @action.id.to_s == id.to_s
|
29
|
+
@actionExists = true
|
30
|
+
return @action
|
31
|
+
elsif @action[:subtasks]
|
32
|
+
return self.find_action(id, @action)
|
33
|
+
end
|
34
|
+
iterator+=1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
attr_reader :name, :component, :id
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/crd_parser/action.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module DTK::CrdParser
|
2
2
|
class Action < BaseClass
|
3
|
+
require_relative('action/executable_action')
|
3
4
|
|
4
5
|
def initialize(name, id, component)
|
5
6
|
@name = name #action name, for example: create node group members
|
@@ -7,13 +8,21 @@ module DTK::CrdParser
|
|
7
8
|
@id = id #action subtask id
|
8
9
|
end
|
9
10
|
|
10
|
-
def self.create_from_kube(client, component_instance,
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def self.create_from_kube(client, component_instance, component_name)
|
12
|
+
Logger.new('/proc/1/fd/1').info 'Action.create_from-kube'
|
13
|
+
component_obj = Component.create_from_kube(client, component_instance, component_name)
|
14
|
+
Logger.new('/proc/1/fd/1').info "Component object is: #{component_obj}"
|
15
|
+
actions = component_obj[:component_def][:executable_actions]
|
16
|
+
Logger.new('/proc/1/fd/1').info "actions are: #{actions}"
|
17
|
+
actions_hash = Hash.new
|
18
|
+
actions.each do |action|
|
19
|
+
Logger.new('/proc/1/fd/1').info action
|
20
|
+
actions_hash[action] = action
|
21
|
+
end
|
22
|
+
# component_name = action[:component]
|
23
|
+
# component = Component.create_from_kube(client, component_instance, component_name)
|
24
|
+
# Action.new(action[:name], action[:id], component)
|
25
|
+
actions
|
17
26
|
end
|
18
27
|
|
19
28
|
protected
|
@@ -21,13 +21,17 @@ module DTK::CrdParser
|
|
21
21
|
componentDef = client.get_componentdef("#{destructured_component[:moduleName]}-#{destructured_component[:componentName]}", module_ref[:namespace])
|
22
22
|
|
23
23
|
componentMetadata = self.metadata(componentDef)
|
24
|
-
|
24
|
+
|
25
25
|
name = componentMetadata[:name]
|
26
26
|
namespace = componentMetadata[:namespace]
|
27
27
|
resourceVersion = componentMetadata[:resourceVersion]
|
28
28
|
|
29
29
|
componentDefSpec = componentDef[:spec] || {}
|
30
|
-
|
30
|
+
if componentDefSpec[:actions]
|
31
|
+
componentDefAction = componentDefSpec[:actions][destructured_component[:action].to_sym]
|
32
|
+
else
|
33
|
+
componentDefAction = componentDefSpec[:actions]
|
34
|
+
end
|
31
35
|
componentDefAttributes = []
|
32
36
|
|
33
37
|
(componentDefSpec[:attributes] || []).each do |attribute|
|
data/lib/crd_parser.rb
CHANGED
@@ -14,15 +14,10 @@ module DTK
|
|
14
14
|
Component.create_from_kube(client, component_instance, component_name)
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.
|
18
|
-
|
19
|
-
#client is kube client
|
20
|
-
#action instance, for example, {name: xxx, namespace: xxx, id: xxx}
|
21
|
-
Action.create_from_kube(client, component_instance, action_instance)
|
17
|
+
def self.parse_crd_to_actions(client, component_instance, component_name)
|
18
|
+
Action.create_from_kube(client, component_instance, component_name)
|
22
19
|
end
|
23
20
|
|
24
|
-
|
25
|
-
Component.create_from_kube(client, component_instance, component_name)
|
26
|
-
end
|
21
|
+
private
|
27
22
|
end
|
28
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtk_crd_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DTK
|
@@ -18,6 +18,7 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- lib/crd_parser.rb
|
20
20
|
- lib/crd_parser/action.rb
|
21
|
+
- lib/crd_parser/action/executable_action.rb
|
21
22
|
- lib/crd_parser/base_class.rb
|
22
23
|
- lib/crd_parser/base_class/helper_mixins.rb
|
23
24
|
- lib/crd_parser/component.rb
|