dtk_crd_parser 0.0.34 → 0.0.35
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 +5 -5
- data/lib/crd_parser/component.rb +2 -1
- data/lib/crd_parser/component_def.rb +2 -5
- data/lib/crd_parser.rb +0 -8
- metadata +3 -3
- data/lib/crd_parser/action.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c2bb87a31649c2e71c4e7bd5911fe4c72bcd9916
|
4
|
+
data.tar.gz: 3f2c9351ec971b3ca46c667d7e4b1fee4a10f622
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ba7f9bd1b69e221e3762394205d854db981d37992f7fa8ad89a6bb6aa9d8369ed4ee95bc0b5a3fb3a3f5a099dd5ff4ec7b6eeddb467cf6ed949c56390cd8ebc
|
7
|
+
data.tar.gz: 46f166241c234e1a27dc2e37513084c2125017cb861cab52d2a7c0520a52c71b8567c59e1d40c8d4088b6058a8b4606633c675db145358ac5b6072ea4910aedc
|
data/lib/crd_parser/component.rb
CHANGED
@@ -2,6 +2,8 @@ module DTK::CrdParser
|
|
2
2
|
class Component < BaseClass
|
3
3
|
require_relative('component/attribute')
|
4
4
|
|
5
|
+
attr_reader :name, :component_def, :attributes
|
6
|
+
|
5
7
|
MODE_DEFAULT = :component_instance
|
6
8
|
def initialize(name, component_def, attributes)
|
7
9
|
@name = name
|
@@ -33,7 +35,6 @@ module DTK::CrdParser
|
|
33
35
|
return nil
|
34
36
|
end
|
35
37
|
|
36
|
-
attr_reader :name, :component_def, :attributes
|
37
38
|
|
38
39
|
end
|
39
40
|
end
|
@@ -2,6 +2,8 @@ module DTK::CrdParser
|
|
2
2
|
class ComponentDef < BaseClass
|
3
3
|
require_relative('component_def/attribute_type_info')
|
4
4
|
|
5
|
+
attr_reader :name, :namespace, :resource_version, :attribute_type_info, :bash_script, :entrypoint, :type
|
6
|
+
|
5
7
|
MODE_DEFAULT = :component_instance
|
6
8
|
|
7
9
|
def initialize(metadata, componentDefAction, componentDefAttributes)
|
@@ -78,10 +80,5 @@ module DTK::CrdParser
|
|
78
80
|
action: action
|
79
81
|
}
|
80
82
|
end
|
81
|
-
|
82
|
-
protected
|
83
|
-
|
84
|
-
attr_reader :name, :namespace, :resource_version, :attribute_type_info, :bash_script, :entrypoint, :type
|
85
|
-
|
86
83
|
end
|
87
84
|
end
|
data/lib/crd_parser.rb
CHANGED
@@ -4,7 +4,6 @@ module DTK
|
|
4
4
|
|
5
5
|
require_relative('crd_parser/component')
|
6
6
|
require_relative('crd_parser/component_def')
|
7
|
-
require_relative('crd_parser/action')
|
8
7
|
|
9
8
|
def self.parse_crd_to_component(client, component_instance, component_name)
|
10
9
|
#component instance has a name and a namespace {name: xxx, namespace: yyy}
|
@@ -12,12 +11,5 @@ module DTK
|
|
12
11
|
#component name is, for example, network-aws::vpc[vpc1]
|
13
12
|
Component.create_from_kube(client, component_instance, component_name)
|
14
13
|
end
|
15
|
-
|
16
|
-
def self.parse_crd_to_action(client, component_instance, action_instance)
|
17
|
-
#component instance has a name and a namespace {name: xxx, namespace: yyy}
|
18
|
-
#client is kube client
|
19
|
-
#action instance, for example, {name: xxx, namespace: xxx, id: xxx}
|
20
|
-
Action.create_from_kube(client, component_instance, action_instance)
|
21
|
-
end
|
22
14
|
end
|
23
15
|
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.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DTK
|
@@ -17,7 +17,6 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/crd_parser.rb
|
20
|
-
- lib/crd_parser/action.rb
|
21
20
|
- lib/crd_parser/base_class.rb
|
22
21
|
- lib/crd_parser/base_class/helper_mixins.rb
|
23
22
|
- lib/crd_parser/component.rb
|
@@ -43,7 +42,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
42
|
- !ruby/object:Gem::Version
|
44
43
|
version: '0'
|
45
44
|
requirements: []
|
46
|
-
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 2.4.5.4
|
47
47
|
signing_key:
|
48
48
|
specification_version: 4
|
49
49
|
summary: Parse kubernetes DTK crd to ruby in memory object!
|
data/lib/crd_parser/action.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module DTK::CrdParser
|
2
|
-
class Action < BaseClass
|
3
|
-
|
4
|
-
def initialize(name, id, component)
|
5
|
-
@name = name #
|
6
|
-
@component = component #this wil point to the corresponding component
|
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
|
-
Logger.new('/proc/1/fd/1').info "FIND ACTION"
|
13
|
-
@actionExists = false
|
14
|
-
action = find_action(action_instance[:id], action_obj[:spec][:action])
|
15
|
-
component_name = action[:component]
|
16
|
-
Logger.new('/proc/1/fd/1').info component_name
|
17
|
-
|
18
|
-
component = Component.create_from_kube(client, component_instance, component_name)
|
19
|
-
Logger.new('/proc/1/fd/1').info component
|
20
|
-
|
21
|
-
Action.new(action[:name], action[:id], component)
|
22
|
-
end
|
23
|
-
|
24
|
-
protected
|
25
|
-
|
26
|
-
@action = nil
|
27
|
-
@actionExists = false
|
28
|
-
def self.find_action(id, actionObject)
|
29
|
-
return @action if @actionExists
|
30
|
-
iterator = 0
|
31
|
-
while (!@actionExists && iterator < actionObject[:subtasks].length)
|
32
|
-
@action = actionObject[:subtasks][iterator]
|
33
|
-
Logger.new('/proc/1/fd/1').info @action
|
34
|
-
|
35
|
-
if @action.id.to_s == id.to_s
|
36
|
-
@actionExists = true
|
37
|
-
return @action
|
38
|
-
elsif @action[:subtasks]
|
39
|
-
return self.find_action(id, @action)
|
40
|
-
end
|
41
|
-
iterator+=1
|
42
|
-
end
|
43
|
-
end
|
44
|
-
attr_reader :name, :component, :id
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|