kuber_kit 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b49fec2466dab5c48794df5e7005bc7084fe0e3056cdaaaee5ed8a41141f421f
4
- data.tar.gz: a6c5d9f5a88e472050bc0077ed33a8116ab3d046a9772a76f581cf1edfdccbac
3
+ metadata.gz: 47a6af30e186e24f434c1d5a777a169eb089e0491177127f4824cfa8af89b0d3
4
+ data.tar.gz: 8ef8e5deeee25dc255e4b1700b9d2c6afe7be5ae34ce0a5a6565e1b6a8092759
5
5
  SHA512:
6
- metadata.gz: f5554eda2be4b918168ff3a353486f7e5aceab2d9d1e006f2601d8af1849b26369d3fd861a30157e549eb4409fc24358f13ad25267e8c72b7df9e03bf1391166
7
- data.tar.gz: f1fd125a176cf1debd8156db61c5d2a83b24671d6113bb12797a8ede8367c94698ad542139b3294739c5d1ab1bd99e654be49e87512ae5ff8a0930d893666602
6
+ metadata.gz: 2307096ca0a11b96a8fa64b31b2611e7fc15c6de8838076ded727f3d1e6ac9541d3f6c3152c84472500b376c0cae5d322b2a6021657a4a0d28aed7c5da5e5579
7
+ data.tar.gz: b8e527ab441c2b2c420728ca670bfeefb094b4fbc0233cb15dea237d0cb7e4fae9a2345f2026c46cb1d528f6e21044d3da0d883cfdb200c16ac6f56777a014de
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ **0.6.4**
2
+ - Improve context vars, allow checking if variable is defined
3
+
1
4
  **0.6.3**
2
5
  - Fix updating artifacts when there is only local artifacts
3
6
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kuber_kit (0.6.3)
4
+ kuber_kit (0.6.4)
5
5
  cli-ui
6
6
  contracts-lite
7
7
  dry-auto_inject (~> 0.7.0)
@@ -1,26 +1,35 @@
1
1
  class KuberKit::Core::ContextHelper::ContextVars
2
2
  attr_reader :parent, :parent_name
3
3
 
4
+ BuildArgUndefined = Class.new(KuberKit::Error)
5
+
4
6
  def initialize(context_vars, parent_name = nil, parent = nil)
5
7
  @context_vars = context_vars
6
8
  @parent_name = parent_name
7
9
  @parent = parent
8
10
  end
9
11
 
10
- def method_missing(name, *args)
11
- if args.size > 0
12
- raise ArgumentError.new("context args does not accept any arguments")
12
+ def read(*variable_names)
13
+ result = self
14
+ variable_names.each do |var|
15
+ result = result.get_variable_value(var)
13
16
  end
17
+ result
18
+ end
14
19
 
15
- value = @context_vars.fetch(name) do
16
- raise(KuberKit::Error, "build arg '#{format_arg(name)}' is not defined, available args: #{@context_vars.inspect}")
17
- end
20
+ def variable_defined?(*variable_names)
21
+ read(*variable_names)
22
+ return true
23
+ rescue BuildArgUndefined
24
+ return false
25
+ end
18
26
 
19
- if value.is_a?(Hash)
20
- return self.class.new(value, name, self)
27
+ def method_missing(name, *args)
28
+ if args.size > 0
29
+ raise ArgumentError.new("context args does not accept any arguments")
21
30
  end
22
31
 
23
- value
32
+ read(name)
24
33
  end
25
34
 
26
35
  def to_h
@@ -31,17 +40,29 @@ class KuberKit::Core::ContextHelper::ContextVars
31
40
  end
32
41
  end
33
42
 
34
- private
35
-
36
- def format_arg(name)
37
- string = [@parent_name, name].compact.join(".")
38
- parent = @parent
43
+ def get_variable_value(variable_name)
44
+ value = @context_vars.fetch(variable_name) do
45
+ raise(BuildArgUndefined, "build arg '#{format_arg(variable_name)}' is not defined, available args: #{@context_vars.inspect}")
46
+ end
39
47
 
40
- while parent do
41
- string = [parent.parent_name, string].compact.join(".")
42
- parent = parent.parent
48
+ if value.is_a?(Hash)
49
+ return self.class.new(value, variable_name, self)
43
50
  end
44
51
 
45
- string
52
+ value
46
53
  end
54
+
55
+ private
56
+
57
+ def format_arg(name)
58
+ string = [@parent_name, name].compact.join(".")
59
+ parent = @parent
60
+
61
+ while parent do
62
+ string = [parent.parent_name, string].compact.join(".")
63
+ parent = parent.parent
64
+ end
65
+
66
+ string
67
+ end
47
68
  end
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
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.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Khaziev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-28 00:00:00.000000000 Z
11
+ date: 2021-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts-lite