dtk_crd_parser 0.0.49 → 0.0.50

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: 87986b80bc66541aa0486d02219457ce068d62a9aba4fa17fbe6d3ab6bcd3867
4
- data.tar.gz: 2207dbe81ce58ccf344d3e42cd002d2dc032f77226c9af59a06c7d4788b476a0
3
+ metadata.gz: b17930d07113d4c72a5ade72bfde5d5ada0c23fe203972c186562347480a2bf4
4
+ data.tar.gz: '06249af234ebd0b082b88a29c67866207ed7933c7a7ee601e994101380530545'
5
5
  SHA512:
6
- metadata.gz: 4df5920359db552d2a70f22b20339f73f87f9f7ba4c743c04a8ea40ef21e67be520a8618dd1f554a25f8d9f743ed1b13b1f7aa3142cfd5cf13d27e1bdb88de82
7
- data.tar.gz: 5403231b980e18f763d04f05a6e3c4e4eb554d21bb5d6e7237220e0910a0631060f5214d98b2befcb3037d5fd7dbdc94b5f1cbf82eac4836c7f190b49bc43c2d
6
+ metadata.gz: 72efb5e8a133bede4f57eb5ce2b6404016087ecf3ed00b99a347023a7ec7fde8fa49a26112fac742df1f5506b3bc9bfebafddf698ecd0e7885308b3e53f96bf9
7
+ data.tar.gz: 15d7e401296342051f6f9ab7738417110c6e39ac9954484324bfb10fba091a3694837087620ae259cdc2fb5cc654070058b6c48e4ccc71be96308fc136546c06
@@ -1,40 +1,30 @@
1
1
  module DTK::CrdParser
2
2
  class ExecutableAction < BaseClass
3
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
4
+ def initialize(params)
5
+ @name = params[:name] || 'create'
6
+ @entrypoint = params[:entrypoint]
7
+ @type = params[:type]
8
+ @bash_script = params[:bash_script]
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)
17
- end
18
-
19
- protected
11
+ private
20
12
 
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
13
+ def self.create_from_kube(client, component_instance, component_name)
14
+ component_obj = Component.create_from_kube(client, component_instance, component_name)
15
+ actions = component_obj.component_def.executable_actions
16
+ executable_actions = Hash.new
17
+ actions.to_hash.each do |action|
18
+ params = {
19
+ :name = action.key,
20
+ :entrypoint = action[:entrypoint],
21
+ :type = action[:type],
22
+ :bash_script = action[:bash_script]
23
+ }
24
+ executable_actions[action.key] = ExecutableAction.new params
35
25
  end
26
+ executable_actions
36
27
  end
37
- attr_reader :name, :component, :id
38
28
 
39
29
  end
40
30
  end
@@ -1,49 +1,10 @@
1
1
  module DTK::CrdParser
2
2
  class Action < BaseClass
3
3
  require_relative('action/executable_action')
4
-
5
- def initialize(name, id, component)
6
- @name = name #action name, for example: create node group members
7
- @component = component #this will point to the corresponding component object, example: ec2::node-group[ng]
8
- @id = id #action subtask id
4
+
5
+ def self.ndxExecutableActions(client, component_instance, component_name)
6
+ ExecutableAction.create_from_kube(client, component_instance, component_name)
9
7
  end
10
-
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.methods-Object.methods}"
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
26
- end
27
-
28
- protected
29
-
30
- @action = nil
31
- @actionExists = false
32
- def self.find_action(id, actionObject)
33
- return @action if @actionExists
34
- iterator = 0
35
- while (!@actionExists && iterator < actionObject[:subtasks].length)
36
- @action = actionObject[:subtasks][iterator]
37
- if @action.id.to_s == id.to_s
38
- @actionExists = true
39
- return @action
40
- elsif @action[:subtasks]
41
- return self.find_action(id, @action)
42
- end
43
- iterator+=1
44
- end
45
- end
46
- attr_reader :name, :component, :id
47
-
8
+
48
9
  end
49
10
  end
data/lib/crd_parser.rb CHANGED
@@ -15,7 +15,7 @@ module DTK
15
15
  end
16
16
 
17
17
  def self.parse_crd_to_actions(client, component_instance, component_name)
18
- Action.create_from_kube(client, component_instance, component_name)
18
+ Action.ndxExecutableActions(client, component_instance, component_name)
19
19
  end
20
20
 
21
21
  private
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.49
4
+ version: 0.0.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - DTK