dtk_crd_parser 0.0.1 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e69f417b48d667384312f79a580f591788d3e677
4
- data.tar.gz: e77320a777a0c480e2defc94db3c3660796215bf
2
+ SHA256:
3
+ metadata.gz: 0b316954698aad33c94166b5b09753eab5cf18e7dcae410dcd44e01238438283
4
+ data.tar.gz: 77bcb6650089a88cb5b807095727307a3d407d90a1b9cbc16a1cc5f84e0d7e26
5
5
  SHA512:
6
- metadata.gz: 7009538c93dc66dcaa01df238cef75eeea2b0d057582c24a6dff709c48cfac148dea0bb11f7f2503c08f7ac4a85b7137a76fc761cbe3f1a99c12b31a9b8ebe11
7
- data.tar.gz: c19e34dad7e41474b19460ad95efba219b4ba4c9d952605460209f0afc6bfbb25c0e94bbe85e94452d6f03606b98710ef7f7ec379b180b11f66c830dfa059ff3
6
+ metadata.gz: 35870fce2c10a834ca1607e44a5162f68009d4799bb185872daa867a24098fd50f8f9d564af1995685bb33210f0349964c399e0dd6e4c1eb673800ba1f30d0a6
7
+ data.tar.gz: 8cfa8662fac82c19972a5b1748deb4513fb23ed76659dc6cc3050a228c7ba13e33e8fafd344a1ed6882f29833b76612920fc30a81703c161421e8f5e6aee2a9f
@@ -21,18 +21,19 @@ module DTK::CrdParser
21
21
  end
22
22
  fail "#{the_method} is not defined in the concrete class #{klass}"
23
23
  end
24
-
24
+
25
25
  def isOnSpecificNode(actionComponent)
26
26
  actionComponent.include? "/"
27
- end
28
-
29
- def destructureActionComponent(actionComponent)
27
+ end
28
+
29
+ def self.destructureActionComponent(actionComponent)
30
+ puts actionComponent
30
31
  # regex to match component: module::name[attrName].action
31
32
  regex = /(.*)::(.*)\[(.*)\].?(.*)/
32
33
  # if component on node group node, get full name first
33
34
  # i.e ec2::node[ng-1]/(node-utility::ssh-access[ubuntu])
34
35
  nodeName, actionComponent = actionComponent.match(/(.*)\/(.*)/).captures if isOnSpecificNode(actionComponent)
35
- compModule, compName, attributeName, action = actionComponent.match(regex).captures
36
+ compModule, compName, attributeName, action = actionComponent.match(regex).captures if actionComponent
36
37
  action = !action.empty? ? action.to_sym : :create
37
38
 
38
39
  if(compModule.nil? || compName.nil? || attributeName.nil?)
@@ -49,4 +50,4 @@ module DTK::CrdParser
49
50
  end
50
51
  end
51
52
  end
52
- end
53
+ end
@@ -18,7 +18,8 @@ module DTK::CrdParser
18
18
 
19
19
  def self.create_from_kube(client, component_instance, component_def_name)
20
20
  puts 'COMPONENT DEF'
21
- module_ref = resolveModuleReference(component_instance.module_refs, component_def_name, destructureActionComponent(component_def_name)[:moduleName])
21
+ module_name = destructureActionComponent(component_def_name)[:moduleName]
22
+ module_ref = resolveModuleReference(component_instance.module_refs, component_def_name, module_name)
22
23
  componentDef = client.get_componentdef(component_def_name, module_ref[:namespace])
23
24
 
24
25
  name = componentDef[:metadata][:name]
@@ -52,6 +53,32 @@ module DTK::CrdParser
52
53
  module_ref
53
54
  end
54
55
 
56
+
57
+ def self.isOnSpecificNode(actionComponent)
58
+ actionComponent.include? "/"
59
+ end
60
+
61
+ def self.destructureActionComponent(actionComponent)
62
+ puts actionComponent
63
+ # regex to match component: module::name[attrName].action
64
+ regex = /(.*)::(.*)\[(.*)\].?(.*)/
65
+ # if component on node group node, get full name first
66
+ # i.e ec2::node[ng-1]/(node-utility::ssh-access[ubuntu])
67
+ nodeName, actionComponent = actionComponent.match(/(.*)\/(.*)/).captures if isOnSpecificNode(actionComponent)
68
+ compModule, compName, attributeName, action = actionComponent.match(regex).captures if actionComponent
69
+ action = !action.empty? ? action.to_sym : :create
70
+
71
+ if(compModule.nil? || compName.nil? || attributeName.nil?)
72
+ raise `Could not resolve component module, name or attribute name for component: #{actionComponent}`
73
+ end
74
+ {
75
+ moduleName: compModule,
76
+ componentName: compName,
77
+ attributeName: attributeName,
78
+ action: action
79
+ }
80
+ end
81
+
55
82
  protected
56
83
 
57
84
  attr_reader :name, :namespace, :attribute_type_info, :bash_script, :entrypoint, :type
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.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - DTK
@@ -42,8 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  requirements: []
45
- rubyforge_project:
46
- rubygems_version: 2.5.2.1
45
+ rubygems_version: 3.0.3
47
46
  signing_key:
48
47
  specification_version: 4
49
48
  summary: Parse kubernetes DTK crd to ruby in memory object!