dtk_crd_parser 0.0.119 → 0.0.120
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/base_class/helper_mixins.rb +20 -0
- data/lib/crd_parser/component.rb +3 -1
- data/lib/crd_parser/component_def.rb +0 -19
- 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: 3e640e4368d77e243f6ac3a6708bd973ee577ee776c6b696463eedab261c7a58
|
4
|
+
data.tar.gz: bfcc94d9e7109279d9cf9bdd36c0e33630ae0dfd26c08e327312ed4f161e1974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fb83a5e7fc5a0b4ddc85d0a47273f299a5894327734ef9e61e5d7bbe0ce63ab810668bd8c82c8342facbe4dfc21e1b5d1fc61ea3325adbb5921f0227145634e
|
7
|
+
data.tar.gz: 5d7a6885f15dd4776d51dcfd6fdf11319d2ae00db076b9dc8ddb982b08bc0b8cbf58ddafa73df261c299c904347dbe7781ec9056b8d33237aa3feb385d9c97c3
|
@@ -3,6 +3,26 @@ module DTK::CrdParser
|
|
3
3
|
module Helper
|
4
4
|
module ClassAndInstanceMixin
|
5
5
|
# Helper functions want to have available in all classes
|
6
|
+
|
7
|
+
def self.destructureActionComponent(actionComponent)
|
8
|
+
# regex to match component: module::name[attrName].action
|
9
|
+
regex = /(.*)::(.*)\[(.*)\].?(.*)/
|
10
|
+
# if component on node group node, get full name first
|
11
|
+
# i.e ec2::node[ng-1]/(node-utility::ssh-access[ubuntu])
|
12
|
+
nodeName, actionComponent = actionComponent.match(/(.*)\/(.*)/).captures if isOnSpecificNode(actionComponent)
|
13
|
+
compModule, compName, attributeName, action = actionComponent.match(regex).captures if actionComponent.match(regex)
|
14
|
+
action = (action && !action.empty?) ? action.to_sym : nil
|
15
|
+
|
16
|
+
if(compModule.nil? || compName.nil? || attributeName.nil?)
|
17
|
+
raise "Could not resolve component module, name or attribute name for component: #{actionComponent}"
|
18
|
+
end
|
19
|
+
{
|
20
|
+
moduleName: compModule,
|
21
|
+
componentName: compName,
|
22
|
+
attributeName: attributeName,
|
23
|
+
action: action
|
24
|
+
}
|
25
|
+
end
|
6
26
|
|
7
27
|
def fail_if_nil(value, property_name)
|
8
28
|
fail Error::Usage, "Property #{property_name} should not be nil" unless value
|
data/lib/crd_parser/component.rb
CHANGED
@@ -19,8 +19,10 @@ module DTK::CrdParser
|
|
19
19
|
component_instance_obj = client.get_component(component_instance[:name], component_instance[:namespace])
|
20
20
|
component_def = ComponentDef.create_from_kube(client, component_instance_obj, component_name)
|
21
21
|
component_attributes = getComponentAttributes(component_name, component_instance_obj[:spec][:components])
|
22
|
-
|
22
|
+
name_value = self.destructureActionComponent(component_name)[:attributeName]
|
23
|
+
Logger.new('/proc/1/fd/1').info "Name value: #{name_value}"
|
23
24
|
attributes = []
|
25
|
+
attributes.push(Attribute.create_from_kube("name", name_value))
|
24
26
|
if component_attributes
|
25
27
|
(component_attributes.to_hash || []).each do |attribute_name, attribute_value|
|
26
28
|
attribute_type_info = (component_def.attribute_type_info
|
@@ -64,25 +64,6 @@ module DTK::CrdParser
|
|
64
64
|
actionComponent.include? "/"
|
65
65
|
end
|
66
66
|
|
67
|
-
def self.destructureActionComponent(actionComponent)
|
68
|
-
# regex to match component: module::name[attrName].action
|
69
|
-
regex = /(.*)::(.*)\[(.*)\].?(.*)/
|
70
|
-
# if component on node group node, get full name first
|
71
|
-
# i.e ec2::node[ng-1]/(node-utility::ssh-access[ubuntu])
|
72
|
-
nodeName, actionComponent = actionComponent.match(/(.*)\/(.*)/).captures if isOnSpecificNode(actionComponent)
|
73
|
-
compModule, compName, attributeName, action = actionComponent.match(regex).captures if actionComponent.match(regex)
|
74
|
-
action = (action && !action.empty?) ? action.to_sym : nil
|
75
|
-
|
76
|
-
if(compModule.nil? || compName.nil? || attributeName.nil?)
|
77
|
-
raise "Could not resolve component module, name or attribute name for component: #{actionComponent}"
|
78
|
-
end
|
79
|
-
{
|
80
|
-
moduleName: compModule,
|
81
|
-
componentName: compName,
|
82
|
-
attributeName: attributeName,
|
83
|
-
action: action
|
84
|
-
}
|
85
|
-
end
|
86
67
|
protected
|
87
68
|
def self.metadata(componentDef)
|
88
69
|
componentDef[:metadata]
|