dtk_crd_parser 0.0.49 → 0.0.50
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/crd_parser/action/executable_action.rb +19 -29
- data/lib/crd_parser/action.rb +4 -43
- data/lib/crd_parser.rb +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: b17930d07113d4c72a5ade72bfde5d5ada0c23fe203972c186562347480a2bf4
|
4
|
+
data.tar.gz: '06249af234ebd0b082b88a29c67866207ed7933c7a7ee601e994101380530545'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
5
|
-
@name = name
|
6
|
-
@
|
7
|
-
@
|
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
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
data/lib/crd_parser/action.rb
CHANGED
@@ -1,49 +1,10 @@
|
|
1
1
|
module DTK::CrdParser
|
2
2
|
class Action < BaseClass
|
3
3
|
require_relative('action/executable_action')
|
4
|
-
|
5
|
-
def
|
6
|
-
|
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.
|
18
|
+
Action.ndxExecutableActions(client, component_instance, component_name)
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|