dtk_crd_parser 0.0.23 → 0.0.24

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
2
  SHA256:
3
- metadata.gz: 9fd752de0c179287773c6096f4cf771eda2d6b6ddcdc41489e44e8c039852576
4
- data.tar.gz: 5c322b20904b4ec6b5bfc4db684efd7be384982018051575e7bf5c831a8d3608
3
+ metadata.gz: 07165f1846624edc95156486af01baacf9296ce003f1882f07ed9ff2368599ae
4
+ data.tar.gz: 67637040432e0bc78c9ec429acb7476d14e5d86bc2e7e45ba06a53a1b7d140cd
5
5
  SHA512:
6
- metadata.gz: 493934f54bb889e46a4ed6a6b198b8cb9acba2fc91fd6448787c027127414b3e0d6d4a37a0fa1380c7cd4db7269acde4168302dddae2cbebe5e7c7c256a59d78
7
- data.tar.gz: 35da808c078b7018780672f04fdf3ad0d6754d23359edee21d55130d6a59125b5e10f4e30d867e5712e66ef7ca55f3f9c89a46c8ebc66f8e3c7bbc9fa1bde32e
6
+ metadata.gz: 804abf6b8dcab1e8e5da70220f6021a021396ea5db18166317fc59f19070938a40830519e2d317ee163deeb92bd425e6c2d597433c86bfdd39c426b404f4d4ac
7
+ data.tar.gz: d49f5da93f8e43b1a9a1332bc3838b5c99625c8df72ed7fb3884ad8277e34d6a22014e04a506db2473a1210871ad0d20b2b51738189342ebc8a07b9803275223
data/lib/crd_parser.rb CHANGED
@@ -6,7 +6,7 @@ module DTK
6
6
  require_relative('crd_parser/component_def')
7
7
 
8
8
  def self.parse_crd_to_component(client, component_instance, component_name)
9
- #component instance has a name and a namespace
9
+ #component instance has a name and a namespace {name: xxx, namespace: yyy}
10
10
  #client is kube client
11
11
  #component name is, for example, network-aws::vpc[vpc1]
12
12
  Component.create_from_kube(client, component_instance, component_name)
@@ -21,30 +21,6 @@ module DTK::CrdParser
21
21
  end
22
22
  fail "#{the_method} is not defined in the concrete class #{klass}"
23
23
  end
24
-
25
- def isOnSpecificNode(actionComponent)
26
- actionComponent.include? "/"
27
- end
28
-
29
- def self.destructureActionComponent(actionComponent)
30
- # regex to match component: module::name[attrName].action
31
- regex = /(.*)::(.*)\[(.*)\].?(.*)/
32
- # if component on node group node, get full name first
33
- # i.e ec2::node[ng-1]/(node-utility::ssh-access[ubuntu])
34
- nodeName, actionComponent = actionComponent.match(/(.*)\/(.*)/).captures if isOnSpecificNode(actionComponent)
35
- compModule, compName, attributeName, action = actionComponent.match(regex).captures if actionComponent.match(regex)
36
- action = (action && !action.empty?) ? action.to_sym : :create
37
- if(compModule.nil? || compName.nil? || attributeName.nil?)
38
- raise "Could not resolve component module, name or attribute name for component: #{actionComponent}"
39
- end
40
- {
41
- moduleName: compModule,
42
- componentName: compName,
43
- attributeName: attributeName,
44
- action: action
45
- }
46
- end
47
-
48
24
  end
49
25
  end
50
26
  end
@@ -13,16 +13,10 @@ module DTK::CrdParser
13
13
  component_instance_obj = client.get_component(component_instance[:name], component_instance[:namespace])
14
14
  component_def = ComponentDef.create_from_kube(client, component_instance_obj, component_name)
15
15
  component_attributes = getComponentAttributes(component_name, component_instance_obj[:spec][:components])
16
- Logger.new('/proc/1/fd/1').info "COMPONENT ATTRIBUTES"
17
- Logger.new('/proc/1/fd/1').info component_attributes.to_hash
18
16
  attributes = []
19
17
  component_attributes.to_hash.each do |attribute_name, attribute_value|
20
- Logger.new('/proc/1/fd/1').info "ATTRIBUTE"
21
- Logger.new('/proc/1/fd/1').info attribute_name
22
18
  attributes.push Attribute.create_from_kube(attribute_name, attribute_value)
23
19
  end
24
- Logger.new('/proc/1/fd/1').info "ATTRIBUTES"
25
- Logger.new('/proc/1/fd/1').info attributes
26
20
  Component.new(component_name, component_def, attributes)
27
21
  end
28
22
 
@@ -5,9 +5,9 @@ module DTK::CrdParser
5
5
  MODE_DEFAULT = :component_instance
6
6
 
7
7
  def initialize(metadata, componentDefAction, componentDefAttributes)
8
- @name = metadata[:name]
9
- @namespace = metadata[:namespace]
10
- @resourceVersion = metadata[:resourceVersion]
8
+ @name = metadata[:name]
9
+ @namespace = metadata[:namespace]
10
+ @resource_version = metadata[:resourceVersion]
11
11
 
12
12
  @bash_script = componentDefAction[:bash_script]
13
13
  @entrypoint = componentDefAction[:entrypoint]
@@ -17,16 +17,14 @@ module DTK::CrdParser
17
17
  end
18
18
 
19
19
  def self.create_from_kube(client, component_instance, component_def_name)
20
- module_name = destructureActionComponent(component_def_name)[:moduleName]
21
- component_name = destructureActionComponent(component_def_name)[:componentName]
22
- action = destructureActionComponent(component_def_name)[:action]
23
- module_ref = resolveModuleReference(component_instance[:references][:module_refs], component_def_name, module_name)
24
-
20
+ { module_name, component_name, attribute_name, action } = destructureActionComponent(component_def_name)[:moduleName]
21
+ module_ref = resolveModuleReference(component_instance[:references][:module_refs], component_def_name, module_name)
22
+
25
23
  componentDef = client.get_componentdef("#{module_name}-#{component_name}", module_ref[:namespace])
26
24
 
27
25
  name = componentDef[:metadata][:name]
28
26
  namespace = componentDef[:metadata][:namespace]
29
- resourceVersion = componentDef[:metadata][:namespace]
27
+ resource_version = componentDef[:metadata][:resourceVersion]
30
28
 
31
29
  componentDefSpec = componentDef[:spec]
32
30
  componentDefAction = componentDefSpec[:actions][action.to_sym]
@@ -39,7 +37,7 @@ module DTK::CrdParser
39
37
  metadata = {
40
38
  name: name,
41
39
  namespace: namespace,
42
- resourceVersion: resourceVersion
40
+ resource_version: resource_version
43
41
  }
44
42
 
45
43
  ComponentDef.new(metadata, componentDefAction, componentDefAttributes)
@@ -83,7 +81,7 @@ module DTK::CrdParser
83
81
 
84
82
  protected
85
83
 
86
- attr_reader :name, :namespace, :attribute_type_info, :bash_script, :entrypoint, :type
84
+ attr_reader :name, :namespace, :resource_version, :attribute_type_info, :bash_script, :entrypoint, :type
87
85
 
88
86
  end
89
87
  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.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - DTK