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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d562bbe941b66feb7526d0ec6addac43fcb098ef66b8f462abcf079a82dacb6
4
- data.tar.gz: d204a7f8c6c3e0f8c42c435ef5df81f06e6b870c0e05f9b15357da9dd75b5727
3
+ metadata.gz: bbb23a6509a68409dfa65e2f1b3be3ec1398d9eb52bf140dba8351741728e9e5
4
+ data.tar.gz: 480c95c6f9db91bc00774c1176798e51b2cb3aaf7d367391df5632e8507209e0
5
5
  SHA512:
6
- metadata.gz: 6598e39a8eb3313b6f66d4847220525e139d274953305ee61d421298390557bfe91e8573765d26fa58336f2c7822221962ed2b0d5517d02c42572f65d228ad99
7
- data.tar.gz: b6107d0bb70bdaa1e466d767603dca007edb6381afee373c4231794aa32d50eb2341ec4368e9c2d59166fbcfc06b38fcf60e0ab397746f8f00c9235ab63b7f5b
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
@@ -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, 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)
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
- componentDefAction = componentDefSpec[:actions][destructured_component[:action].to_sym] if componentDefSpec[:actions]
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.parse_crd_to_action(client, component_instance, action_instance)
18
- #component instance has a name and a namespace {name: xxx, namespace: yyy}
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
- def self.parse_crd_to_executable_action(client, component_instance, component_name)
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.43
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