dtk_crd_parser 0.0.7 → 0.0.8
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.rb +4 -1
- data/lib/crd_parser/base_class/helper_mixins.rb +1 -1
- data/lib/crd_parser/component.rb +8 -0
- data/lib/crd_parser/component_def.rb +1 -6
- 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: 40f46b80f3129571814edba062020aae105a08c81392b6e9750bb5226fa5e825
|
4
|
+
data.tar.gz: f6631ba731f2ce8a197b10090744bacb4d40710197c08d2d6fc6a32068037325
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42f25b2597121d3afbc40aa3a8f94708dd4cd2541bc587ba4864001916688253f873eba992905d0384f77714a60c91367e379f299310faf0cfe0baad8bfcbe25
|
7
|
+
data.tar.gz: 329cb709c46b15158fdd768e34aa9e8608673d0ed1c707c34afd8ecb2e43303c429a938ca2a4dac93721dbeb5fb73f3f86be91fdf49aaff200e9cede9f8e390d
|
data/lib/crd_parser.rb
CHANGED
@@ -9,7 +9,10 @@ module DTK
|
|
9
9
|
#component instance has a name and a namespace
|
10
10
|
#client is kube client
|
11
11
|
#component name is, for example, network-aws::vpc[vpc1]
|
12
|
-
|
12
|
+
puts 'Parsing crd...'
|
13
|
+
comp = Component.create_from_kube(client, component_instance, component_name)
|
14
|
+
puts comp
|
15
|
+
comp
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
@@ -35,7 +35,7 @@ module DTK::CrdParser
|
|
35
35
|
compModule, compName, attributeName, action = actionComponent.match(regex).captures if actionComponent.match(regex)
|
36
36
|
action = (action && !action.empty?) ? action.to_sym : :create
|
37
37
|
if(compModule.nil? || compName.nil? || attributeName.nil?)
|
38
|
-
raise
|
38
|
+
raise "Could not resolve component module, name or attribute name for component: #{actionComponent}"
|
39
39
|
end
|
40
40
|
{
|
41
41
|
moduleName: compModule,
|
data/lib/crd_parser/component.rb
CHANGED
@@ -10,19 +10,27 @@ module DTK::CrdParser
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.create_from_kube(client, component_instance, component_name)
|
13
|
+
puts 'Component instance object :'
|
13
14
|
component_instance_obj = client.get_component(component_instance[:name], component_instance[:namespace])
|
15
|
+
puts component_instance_obj
|
14
16
|
component_def = ComponentDef.create_from_kube(client, component_instance_obj, component_name)
|
17
|
+
puts 'Component def:'
|
18
|
+
puts component_def
|
15
19
|
component_attributes = getComponentAttributes(component_name, component_instance_obj[:spec][:components])
|
20
|
+
puts component_attributes
|
16
21
|
attributes = []
|
17
22
|
component_attributes.each do |attr|
|
18
23
|
attributes.push Attribute.create_from_kube(attr)
|
19
24
|
end
|
25
|
+
puts 'Attributes are:'
|
26
|
+
puts attributes
|
20
27
|
Component.new(component_name, component_def, attributes)
|
21
28
|
end
|
22
29
|
|
23
30
|
protected
|
24
31
|
|
25
32
|
def self.getComponentAttributes(fullComponentName, components)
|
33
|
+
puts 'Get component attributes'
|
26
34
|
fullComponentName.gsub!('_', '-')
|
27
35
|
component = components.each do |component|
|
28
36
|
componentObj = component[fullComponentName]
|
@@ -63,17 +63,12 @@ module DTK::CrdParser
|
|
63
63
|
regex = /(.*)::(.*)\[(.*)\].?(.*)/
|
64
64
|
# if component on node group node, get full name first
|
65
65
|
# i.e ec2::node[ng-1]/(node-utility::ssh-access[ubuntu])
|
66
|
-
puts 'Action component is: '
|
67
|
-
puts actionComponent
|
68
|
-
puts isOnSpecificNode(actionComponent)
|
69
66
|
nodeName, actionComponent = actionComponent.match(/(.*)\/(.*)/).captures if isOnSpecificNode(actionComponent)
|
70
|
-
puts 'captures: '
|
71
|
-
puts actionComponent.match(regex)
|
72
67
|
compModule, compName, attributeName, action = actionComponent.match(regex).captures if actionComponent.match(regex)
|
73
68
|
action = (action && !action.empty?) ? action.to_sym : :create
|
74
69
|
|
75
70
|
if(compModule.nil? || compName.nil? || attributeName.nil?)
|
76
|
-
raise
|
71
|
+
raise "Could not resolve component module, name or attribute name for component: #{actionComponent}"
|
77
72
|
end
|
78
73
|
{
|
79
74
|
moduleName: compModule,
|