kuber_kit 0.1.4 → 0.1.5

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: d85e9b30ebb43f4fe0a056823e3eeda6f878784555fa909df004e46522d750ec
4
- data.tar.gz: 441270e1f147862ff75f999606bfafa7e467efde71765d27490e8f6afdd74740
3
+ metadata.gz: b5df957bf6c31a193caef5d2fc163be4d925ba6dc3bd61f2d98c47f0eee2bb42
4
+ data.tar.gz: 701748c782360287b41acd34dcd33a3c8d9192a2ba91685a5355dddbe4b19789
5
5
  SHA512:
6
- metadata.gz: 0d112105c8b7e268a528b59097028f9c483ac921d3b584bb372ba33f23595d3d8614f4a7251b75498934c1f0d365e5eed3d9c2b237a9f30d5a235cbd290150c8
7
- data.tar.gz: '068e6d864886eb38d6ebd9f8ac10358bb3f220cabe0c38a67df9b6a886b07b224083586be4ddd7320691b05b0420af8f053f9f2d1ed6c2a7c81accd4dce6f4a0'
6
+ metadata.gz: f4d10fbac924851b0552f1b833e8080203277245055717a5a7592437284eb9a5cd0535c369764ca474bc7a09686517254423fec45aeb2ccd8568d22c1851cf63
7
+ data.tar.gz: 1972b5f5cdd6cb8e8b1f33ae210ac783f3ff55e1c36f6304c933c2a43b3b335ff40b9400fd725be957227b3ed8160327d8d19f0352abf9b9596e4f0b0855716d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kuber_kit (0.1.4)
4
+ kuber_kit (0.1.5)
5
5
  cli-ui
6
6
  contracts-lite
7
7
  dry-auto_inject
@@ -15,4 +15,8 @@ class KuberKit::Core::ContextHelper::ServiceHelper < KuberKit::Core::ContextHelp
15
15
  def service_uri
16
16
  @service.uri
17
17
  end
18
+
19
+ def attribute(attribute_name)
20
+ @service.attribute(attribute_name)
21
+ end
18
22
  end
@@ -1,20 +1,32 @@
1
1
  class KuberKit::Core::Service
2
- attr_reader :name, :template_name, :tags, :images
2
+ AttributeNotSet = Class.new(Indocker::Error)
3
+
4
+ attr_reader :name, :template_name, :tags, :images, :attributes
3
5
 
4
6
  Contract KeywordArgs[
5
7
  name: Symbol,
6
8
  template_name: Symbol,
7
9
  tags: ArrayOf[Symbol],
8
10
  images: ArrayOf[Symbol],
11
+ attributes: HashOf[Symbol => Any],
9
12
  ] => Any
10
- def initialize(name:, template_name:, tags:, images:)
13
+ def initialize(name:, template_name:, tags:, images:, attributes:)
11
14
  @name = name
12
15
  @template_name = template_name
13
16
  @tags = tags
14
17
  @images = images
18
+ @attributes = attributes
15
19
  end
16
20
 
17
21
  def uri
18
- name.to_s.sub("_", "-")
22
+ name.to_s.gsub("_", "-")
23
+ end
24
+
25
+ def attribute(attribute_name)
26
+ unless attributes.has_key?(attribute_name.to_sym)
27
+ raise AttributeNotSet, "attribute #{attribute_name} was not set"
28
+ end
29
+
30
+ attributes[attribute_name.to_sym]
19
31
  end
20
32
  end
@@ -12,6 +12,7 @@ class KuberKit::Core::ServiceDefinition
12
12
  template_name: get_value(@template_name),
13
13
  tags: Array(get_value(@tags)).map(&:to_sym),
14
14
  images: Array(get_value(@images)).map(&:to_sym),
15
+ attributes: get_value(@attributes),
15
16
  )
16
17
  end
17
18
 
@@ -33,6 +34,12 @@ class KuberKit::Core::ServiceDefinition
33
34
  self
34
35
  end
35
36
 
37
+ def attributes(value = nil, &block)
38
+ @attributes = block_given? ? block : value
39
+
40
+ self
41
+ end
42
+
36
43
  private
37
44
  def get_value(variable)
38
45
  variable.is_a?(Proc) ? variable.call : variable
@@ -12,7 +12,8 @@ class KuberKit::Core::ServiceFactory
12
12
  name: service_attrs.name,
13
13
  template_name: service_attrs.template_name,
14
14
  tags: service_attrs.tags,
15
- images: service_attrs.images
15
+ images: service_attrs.images,
16
+ attributes: service_attrs.attributes || {}
16
17
  )
17
18
  end
18
19
  end
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuber_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Khaziev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-30 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts-lite