persistence-providers 0.0.3.1 → 0.0.3.2

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: 7ac2828e10383c9590347d210c09ffd97640c80794cc0078290de10d8010685c
4
- data.tar.gz: ef1e7376786ed2c13d7e2457351185285f385c1d99818ead0c5171d921d094e7
3
+ metadata.gz: 30043309dd4928f64a7577e8045035f0208b9fd8bde9c9a4f378ddc1f6cadc2d
4
+ data.tar.gz: 46e990e3aa194698a9a8930a3529a4068ba3f9d9dae836bc6353e22504fd3e2a
5
5
  SHA512:
6
- metadata.gz: d13cb086750ea5407ad6c9e932672031adbb9aee66c85d15043bd0af770ddeb6e605acf721d3bea50f534198cdd6ac58d95ff6313bf796e75751b3616b4f55ae
7
- data.tar.gz: 61c45ed7d35a5f68beab292ee7f4830298b58060b83dc29e145340352195cb82095812c778a9df36c51f20356f1a0b6ce767f26168ff5138cd9ff20c389875d0
6
+ metadata.gz: 61edcdffbc29dd611e1874e1f8b4d422f5cf3183b675d11aedb446c7c78932946b76086e367f7ce1c1f2447f6bbba86341ae191f7071b1c4a2c0456ed6c0fa41
7
+ data.tar.gz: 635650ee5cba06e3d5cb46cd953dba7bc6349d3a90c96f877c23087f12848b718d9a0b782beed7fffbc60117f8d47355e7332a6b13221e8af779ee5c3367e7e7
@@ -1,7 +1,7 @@
1
1
  module DTK
2
2
  module State
3
3
  require_relative 'crd_client'
4
- require_relative 'state/crd_component'
4
+ require_relative 'state/crd_assembly'
5
5
  require_relative 'state/component'
6
6
  require_relative 'state/component_def'
7
7
  require_relative 'state/executable_action'
@@ -31,21 +31,21 @@ module DTK::State
31
31
  # @encrypted = attribute_content[:encrypted] || false
32
32
  end
33
33
 
34
- def self.get(namespace, crd_component_name, component_instance_name, attribute_name, opts = {})
34
+ def self.get(namespace, assembly_name, component_name, attribute_name, opts = {})
35
35
  # getting attribute here because we can reuse it if it's stored in crd
36
- # when we decide to not store attribute value as part of component_instance crd we can overwrite this
37
- component_instance = Component.get(namespace, crd_component_name, component_instance_name, opts)
38
- attribute_content = component_instance.attributes.find{ |attribute| attribute.name == attribute_name }
36
+ # when we decide to not store attribute value as part of assembly crd we can overwrite this
37
+ assembly = Component.get(namespace, assembly_name, component_name, opts)
38
+ attribute_content = assembly.attributes.find{ |attribute| attribute.name == attribute_name }
39
39
 
40
- fail Error.new("Unable to find attribute '#{attribute_name}' in provided component instance") if attribute_content.nil? || attribute_content.empty?
40
+ fail Error.new("Unable to find attribute '#{attribute_name}' in provided assembly") if attribute_content.nil? || attribute_content.empty?
41
41
 
42
- attribute = self.new(attribute_name, attribute_content, component_instance)
42
+ attribute = self.new(attribute_name, attribute_content, assembly)
43
43
  provider_class = provider_class_name(attribute, opts)
44
44
  # return already fetched attribute value if provider is KubeCrd
45
45
  return attribute if provider_class == 'KubeCrd'
46
46
 
47
47
  # for KubeCrd this will do the same work we did in provider_class_name method to find temporal param
48
- self.class.const_get(provider_class).get(component_instance_name, attribute_name, opts)
48
+ self.class.const_get(provider_class).get(component_name, attribute_name, opts)
49
49
  end
50
50
 
51
51
  def to_hash
@@ -11,7 +11,7 @@ module DTK::State
11
11
  protected
12
12
 
13
13
  def required_params
14
- [:namespace, :crd_component_name, :component_instance_name, :attribute_name, :task_id]
14
+ [:namespace, :component_name, :assembly_name, :attribute_name, :task_id]
15
15
  end
16
16
 
17
17
  end
@@ -11,7 +11,7 @@ module DTK::State
11
11
  protected
12
12
 
13
13
  def required_params
14
- [:namespace, :crd_component_name, :component_instance_name, :task_id, :attribute_name, :task_id, :correlator_type]
14
+ [:namespace, :component_name, :assembly_name, :task_id, :attribute_name, :task_id, :correlator_type]
15
15
  end
16
16
 
17
17
  end
@@ -22,7 +22,7 @@ module DTK::State
22
22
  def get_last_point(params_hash = {})
23
23
  begin
24
24
  check_params_hash(params_hash)
25
- flux_query = 'from(bucket:"' + client.connection_parameters[:bucket] + '") |> range(start:-5) |> filter(fn: (r) => r._measurement == "' + name.to_s + '")' + flux_filter(params_hash) + ' |> last()' + '|> drop(columns: ["_start", "_stop", "_field", "_measurement", "attribute_name", "component_instance_name", "task_id", "crd_component_name", "namespace"])'
25
+ flux_query = 'from(bucket:"' + client.connection_parameters[:bucket] + '") |> range(start:-5) |> filter(fn: (r) => r._measurement == "' + name.to_s + '")' + flux_filter(params_hash) + ' |> last()' + '|> drop(columns: ["_start", "_stop", "_field", "_measurement", "attribute_name", "assembly_name", "task_id", "component_name", "namespace"])'
26
26
  result = self.client.query(flux_query)
27
27
  result.values.map(&:records).flatten.map(&:values)
28
28
  rescue => error
@@ -11,8 +11,8 @@ module DTK::State
11
11
  @measurement = @client.measurement_helper(measurement_name)
12
12
  end
13
13
 
14
- def get(namespace, crd_component_name, component_instance_name, attribute_name, opts = {})
15
- required_tags = get_required_tags(namespace, crd_component_name, component_instance_name, attribute_name)
14
+ def get(namespace, component_name, assembly_name, attribute_name, opts = {})
15
+ required_tags = get_required_tags(namespace, component_name, assembly_name, attribute_name)
16
16
  if opts[:provider] == "correlation"
17
17
  errors = client.measurement_helper(:errors)
18
18
  required_tags.merge!({ correlator_type: opts[:entrypoint].split("/").last.split(".")[0] })
@@ -23,14 +23,14 @@ module DTK::State
23
23
  end
24
24
  end
25
25
 
26
- def write(namespace, crd_component_name, component_instance_name, attribute_name, value, opts = {}, timestamp = nil)
26
+ def write(namespace, component_name, assembly_name, attribute_name, value, opts = {}, timestamp = nil)
27
27
  if opts[:provider] == "correlation"
28
28
  errors = client.measurement_helper(:errors)
29
- required_tags = get_required_tags(namespace, crd_component_name, component_instance_name, attribute_name)
29
+ required_tags = get_required_tags(namespace, component_name, assembly_name, attribute_name)
30
30
  required_tags.merge!({ correlator_type: opts[:entrypoint].split("/").last.split(".")[0] })
31
31
  errors.write(value.to_s, required_tags, timestamp)
32
32
  elsif
33
- required_tags = get_required_tags(namespace, crd_component_name, component_instance_name, attribute_name)
33
+ required_tags = get_required_tags(namespace, component_name, assembly_name, attribute_name)
34
34
  measurement.write(value, required_tags, timestamp)
35
35
  end
36
36
  end
@@ -86,11 +86,11 @@ module DTK::State
86
86
 
87
87
  private
88
88
 
89
- def get_required_tags(namespace, crd_component_name, component_instance_name, attribute_name)
89
+ def get_required_tags(namespace, component_name, assembly_name, attribute_name)
90
90
  required_tags = {
91
91
  namespace: namespace,
92
- crd_component_name: crd_component_name,
93
- component_instance_name: component_instance_name,
92
+ component_name: component_name,
93
+ assembly_name: assembly_name,
94
94
  attribute_name: attribute_name,
95
95
  task_id: "1"
96
96
  }
@@ -1,10 +1,10 @@
1
1
  module DTK::State
2
2
  class Component::Attribute
3
3
  class KubeCrd < self
4
- def get(namespace, crd_component_name, component_instance_name, attribute_name, opts = {})
5
- component_instance = Component.get(namespace, crd_component_name, component_instance_name, opts)
6
- attribute = component_instance.attributes.find{ |attribute| attribute.name == attribute_name }
7
- Attribute.new(attribute_name, attribute, component_instance)
4
+ def get(namespace, assembly_name, component_name, attribute_name, opts = {})
5
+ assembly = Component.get(namespace, assembly_name, component_name, opts)
6
+ attribute = assembly.attributes.find{ |attribute| attribute.name == attribute_name }
7
+ Attribute.new(attribute_name, attribute, assembly)
8
8
  end
9
9
  end
10
10
  end
@@ -15,10 +15,10 @@ module DTK::State
15
15
 
16
16
  # opts can have keys
17
17
  # task_id
18
- def self.get(namespace, crd_component_name, component_name, opts = {})
19
- crd_component = CrdComponent.get(namespace, crd_component_name, opts)
20
- if matching_component = crd_component.components.find{ |cmp| cmp.to_hash.keys.first.to_s == component_name }
21
- Component.new(component_name, matching_component[component_name], crd_component, opts)
18
+ def self.get(crd_assembly_namespace, crd_assembly_name, component_name, opts = {})
19
+ crd_assembly = CrdAssembly.get(crd_assembly_namespace, crd_assembly_name, opts)
20
+ if matching_component = crd_assembly.components.find{ |cmp| cmp.to_hash.keys.first.to_s == component_name }
21
+ Component.new(component_name, matching_component[component_name], crd_assembly, opts)
22
22
  end
23
23
  end
24
24
 
@@ -27,8 +27,8 @@ module DTK::State
27
27
  # format:
28
28
  # hash
29
29
  # kubernetes - return attributes in raw format from kubeclient
30
- def self.get_attributes(namespace, crd_component_name, component_name, opts = {})
31
- component = get(namespace, crd_component_name, component_name, opts)
30
+ def self.get_attributes(crd_assembly_namespace, crd_assembly_name, component_name, opts = {})
31
+ component = get(crd_assembly_namespace, crd_assembly_name, component_name, opts)
32
32
  component.attributes(opts)
33
33
  end
34
34
 
@@ -1,5 +1,5 @@
1
1
  module DTK::State
2
- class CrdComponent
2
+ class CrdAssembly
3
3
  attr_reader :name, :namespace, :crd_content, :components, :references
4
4
 
5
5
  def initialize(namespace, name, crd_content)
@@ -12,8 +12,8 @@ module DTK::State
12
12
 
13
13
  def self.get(namespace, name, opts = {})
14
14
  # crd_component = ::DTK::CrdClient.instance.kubeclient.get_component(name, namespace)
15
- crd_component = ::DTK::CrdClient.get_kubeclient(opts).get_assembly(name, namespace)
16
- CrdComponent.new(namespace, name, crd_component)
15
+ crd_assembly = ::DTK::CrdClient.get_kubeclient(opts).get_assembly(name, namespace)
16
+ CrdAssembly.new(namespace, name, crd_assembly)
17
17
  end
18
18
 
19
19
  # components can be:
@@ -9,8 +9,8 @@ module DTK::State
9
9
  @bash_script = params[:bash_script]
10
10
  end
11
11
 
12
- def self.get(namespace, crd_component_name, component_name, action_name, opts = {})
13
- component_obj = Component.get(namespace, crd_component_name, component_name, opts)
12
+ def self.get(crd_assembly_namespace, crd_assembly_name, component_name, action_name, opts = {})
13
+ component_obj = Component.get(crd_assembly_namespace, crd_assembly_name, component_name, opts)
14
14
  actions = component_obj.component_def.executable_actions
15
15
  action = actions[action_name]
16
16
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'persistence-providers'
3
- spec.version = '0.0.3.1'
3
+ spec.version = '0.0.3.2'
4
4
  spec.author = 'Reactor8'
5
5
  spec.email = 'support@reactor8.com'
6
6
  spec.description = %q{Persistence providers plugin}
data/test.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require_relative 'lib/persistence_providers'
2
2
  require 'byebug'
3
3
  byebug
4
- DTK::State::CrdComponent.get('aldin', 'aldin', {kubeclient: 'test'})
5
- DTK::State::CrdComponent.new('aaa', 'bbb', { spec: { components: 'some_components'}}, {kubernetes_client: 'test'})
4
+ DTK::State::CrdAssembly.get('aldin', 'aldin', {kubeclient: 'test'})
5
+ DTK::State::CrdAssembly.new('aaa', 'bbb', { spec: { components: 'some_components'}}, {kubernetes_client: 'test'})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: persistence-providers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.1
4
+ version: 0.0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reactor8
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-22 00:00:00.000000000 Z
11
+ date: 2020-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kubeclient
@@ -73,7 +73,7 @@ files:
73
73
  - lib/state/component/providers/kube_crd.rb
74
74
  - lib/state/component_def.rb
75
75
  - lib/state/component_def/attribute_type_info.rb
76
- - lib/state/crd_component.rb
76
+ - lib/state/crd_assembly.rb
77
77
  - lib/state/executable_action.rb
78
78
  - lib/state/workflow_instance.rb
79
79
  - lib/state/workflow_instance/attribute_type_info.rb