kuber_kit 0.6.2 → 0.7.1

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: b9436f738b564585856ce6daa51aae3b55eeb0b33e68710c6d8be4b8a9cfa465
4
- data.tar.gz: 12ed77727bfb8af6d719576e2676e5f3d12d9d5ab1b9a69b77c3804f4e64e175
3
+ metadata.gz: 5384a7795eb49fdf9beeb9481fc03e871fb001cda72d365a646f2ca3885309e9
4
+ data.tar.gz: 229512248e019960f5f178cdd4a5c7ca99ca808d70e7286884fc152570366e73
5
5
  SHA512:
6
- metadata.gz: 31b571193f5130591b1f2bcfc73e42bb01bb5285beffbab26909e4ebccc765bc161b73897cc3d46e70ed2bc5975e445e02e6a0855493bb8ecad19f7b638d8685
7
- data.tar.gz: 306aa5f9f87e075abc9fa65884ae211b9235039950dc1985c2f789d85b518f72d46a44c67def3f8af134b7cb1e6fc023b8755dd509f28721fa412bba3fa982ab
6
+ metadata.gz: 8ab657438fc9c8463528fed4938518365abda3b944416600ad3032deff7deb8afbd2c90cca99b1fea97f9d148d2b8df77759b11a10c441fa7d7c1f672897641e
7
+ data.tar.gz: 70824969dae53951c1ac194922dc76d3773d6f65e8c51ff3589c46de9ec702d027a55ad9516e9846b81cde969c2ebab7cdb84be5f5617b216854929fd56c6bdb
@@ -19,7 +19,7 @@ jobs:
19
19
  runs-on: ubuntu-latest
20
20
  strategy:
21
21
  matrix:
22
- ruby-version: ['2.5', '2.7']
22
+ ruby-version: ['2.5', '2.7', '3.0']
23
23
 
24
24
  steps:
25
25
  - uses: actions/checkout@v2
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
- .DS_Store
12
+ .DS_Store
13
+ Gemfile.lock
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.8
1
+ 2.6.8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ **0.7.0**
2
+ - Added Ruby 3.0 support
3
+
4
+ **0.6.4**
5
+ - Improve context vars, allow checking if variable is defined
6
+
7
+ **0.6.3**
8
+ - Fix updating artifacts when there is only local artifacts
9
+
1
10
  **0.6.2**
2
11
  - Added an ability to return build vars as a hash value.
3
12
  - Skip local artifacts while updating configuration, it sometimes produce an error
data/kuber_kit.gemspec CHANGED
@@ -23,15 +23,26 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_dependency "contracts-lite"
27
- spec.add_dependency "dry-auto_inject", "~> 0.7.0"
26
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
27
+ spec.add_dependency "contracts", '0.17.0'
28
+ else
29
+ spec.add_dependency "contracts", '0.16.0'
30
+ end
31
+
32
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6.0')
33
+ spec.add_dependency "dry-auto_inject", "~> 0.8.0"
34
+ else
35
+ spec.add_dependency "dry-auto_inject", "~> 0.7.0"
36
+ end
37
+
28
38
  spec.add_dependency "thor"
29
39
  spec.add_dependency "cli-ui"
30
40
  spec.add_dependency "net-ssh"
31
41
  spec.add_dependency "tty-prompt"
32
42
  spec.add_dependency "dry-container", "~> 0.7.2"
43
+ spec.add_dependency "dry-configurable", "~> 0.12.1"
33
44
 
34
- spec.add_development_dependency "bundler", "~> 1.17"
45
+ spec.add_development_dependency "bundler", "~> 2.2"
35
46
  spec.add_development_dependency "rake", "~> 10.0"
36
47
  spec.add_development_dependency "rspec", "~> 3.0"
37
48
  spec.add_development_dependency "pry"
@@ -99,12 +99,12 @@ class KuberKit::Actions::ConfigurationLoader
99
99
  end
100
100
 
101
101
  def update_artifacts(artifacts)
102
- return unless artifacts.any?
103
-
104
102
  # Skip local artifacts, they sometimes produce error in CLI::UI::SpinGroup task,
105
103
  # because the task is executed too quickly
106
104
  not_local_artifacts = artifacts.reject{ |a| a.is_a?(KuberKit::Core::Artifacts::Local) }
107
105
 
106
+ return unless not_local_artifacts.any?
107
+
108
108
  artifact_task_group = ui.create_task_group
109
109
  not_local_artifacts.each do |artifact|
110
110
  artifact_task_group.add("Updating #{artifact.name.to_s.yellow}") do |task|
@@ -2,9 +2,6 @@ class KuberKit::ArtifactsSync::ArtifactUpdater
2
2
  ResolverNotFoundError = Class.new(KuberKit::NotFoundError)
3
3
 
4
4
  include KuberKit::Import[
5
- "artifacts_sync.git_artifact_resolver",
6
- "artifacts_sync.null_artifact_resolver",
7
-
8
5
  "ui"
9
6
  ]
10
7
 
@@ -19,8 +16,6 @@ class KuberKit::ArtifactsSync::ArtifactUpdater
19
16
  end
20
17
 
21
18
  def update(shell, artifact)
22
- add_default_resolvers
23
-
24
19
  resolver = @@resolvers[artifact.class]
25
20
 
26
21
  ui.print_debug "ArtifactUpdater", "Updating artifact #{artifact.name.to_s.green}"
@@ -29,13 +24,4 @@ class KuberKit::ArtifactsSync::ArtifactUpdater
29
24
 
30
25
  resolver.resolve(shell, artifact)
31
26
  end
32
-
33
- def add_default_resolvers
34
- use_resolver(git_artifact_resolver, artifact_class: KuberKit::Core::Artifacts::Git)
35
- use_resolver(null_artifact_resolver, artifact_class: KuberKit::Core::Artifacts::Local)
36
- end
37
-
38
- def reset!
39
- @@resolvers = {}
40
- end
41
27
  end
@@ -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
@@ -0,0 +1,32 @@
1
+ class KuberKit::Defaults
2
+ class << self
3
+ def init
4
+ return if @_initialized
5
+ @_initialized = true
6
+ init!
7
+ end
8
+
9
+ def init!
10
+ KuberKit::Container["artifacts_sync.artifact_updater"].use_resolver(
11
+ KuberKit::Container["artifacts_sync.git_artifact_resolver"],
12
+ artifact_class: KuberKit::Core::Artifacts::Git
13
+ )
14
+ KuberKit::Container["artifacts_sync.artifact_updater"].use_resolver(
15
+ KuberKit::Container["artifacts_sync.null_artifact_resolver"],
16
+ artifact_class: KuberKit::Core::Artifacts::Local
17
+ )
18
+ KuberKit::Container["env_file_reader.reader"].use_reader(
19
+ KuberKit::Container["env_file_reader.strategies.artifact_file"],
20
+ env_file_class: KuberKit::Core::EnvFiles::ArtifactFile
21
+ )
22
+ KuberKit::Container["env_file_reader.reader"].use_reader(
23
+ KuberKit::Container["env_file_reader.strategies.env_group"],
24
+ env_file_class: KuberKit::Core::EnvFiles::EnvGroup
25
+ )
26
+ KuberKit::Container["template_reader.reader"].use_reader(
27
+ KuberKit::Container["template_reader.strategies.artifact_file"],
28
+ template_class: KuberKit::Core::Templates::ArtifactFile
29
+ )
30
+ end
31
+ end
32
+ end
@@ -1,16 +1,6 @@
1
1
  class KuberKit::EnvFileReader::Reader
2
2
  ReaderNotFoundError = Class.new(KuberKit::NotFoundError)
3
-
4
- include KuberKit::Import[
5
- "env_file_reader.strategies.artifact_file",
6
- "env_file_reader.strategies.env_group",
7
- ]
8
-
9
- def initialize(**injected_deps)
10
- super(injected_deps)
11
- add_default_strategies
12
- end
13
-
3
+
14
4
  def use_reader(env_file_reader, env_file_class:)
15
5
  @@readers ||= {}
16
6
 
@@ -28,14 +18,4 @@ class KuberKit::EnvFileReader::Reader
28
18
 
29
19
  reader.read(shell, env_file)
30
20
  end
31
-
32
- def reset!
33
- @@readers = {}
34
- end
35
-
36
- private
37
- def add_default_strategies
38
- use_reader(artifact_file, env_file_class: KuberKit::Core::EnvFiles::ArtifactFile)
39
- use_reader(env_group, env_file_class: KuberKit::Core::EnvFiles::EnvGroup)
40
- end
41
21
  end
@@ -8,8 +8,8 @@ class KuberKit::ServiceDeployer::Deployer
8
8
  "service_deployer.strategies.docker_compose"
9
9
  ]
10
10
 
11
- def initialize(**injected_deps)
12
- super(injected_deps)
11
+ def initialize(**injected_deps, &block)
12
+ super(**injected_deps)
13
13
  add_default_strategies
14
14
  end
15
15
 
@@ -1,15 +1,6 @@
1
1
  class KuberKit::TemplateReader::Reader
2
2
  ReaderNotFoundError = Class.new(KuberKit::NotFoundError)
3
3
 
4
- include KuberKit::Import[
5
- "template_reader.strategies.artifact_file",
6
- ]
7
-
8
- def initialize(**injected_deps)
9
- super(injected_deps)
10
- add_default_strategies
11
- end
12
-
13
4
  def use_reader(template_reader, template_class:)
14
5
  @@readers ||= {}
15
6
 
@@ -27,13 +18,4 @@ class KuberKit::TemplateReader::Reader
27
18
 
28
19
  reader.read(shell, template)
29
20
  end
30
-
31
- def reset!
32
- @@readers = {}
33
- end
34
-
35
- private
36
- def add_default_strategies
37
- use_reader(artifact_file, template_class: KuberKit::Core::Templates::ArtifactFile)
38
- end
39
21
  end
@@ -46,6 +46,7 @@ class KuberKit::UI::Simple
46
46
  class TaskGroup
47
47
  def initialize(task_class)
48
48
  @task_class = task_class
49
+ @tasks
49
50
  end
50
51
 
51
52
  def add(task_title, &task_block)
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.6.2"
2
+ VERSION = "0.7.1"
3
3
  end
data/lib/kuber_kit.rb CHANGED
@@ -208,6 +208,7 @@ module KuberKit
208
208
  autoload :CLI, 'cli'
209
209
  autoload :Container, 'container'
210
210
  autoload :Configs, 'configs'
211
+ autoload :Defaults, 'defaults'
211
212
 
212
213
  Import = Dry::AutoInject(Container)
213
214
 
@@ -297,4 +298,6 @@ module KuberKit
297
298
  end
298
299
  end
299
300
 
301
+ KuberKit::Defaults.init
302
+
300
303
  require 'kuber_kit/extensions/indocker_compat'
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuber_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.1
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-26 00:00:00.000000000 Z
11
+ date: 2021-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: contracts-lite
14
+ name: contracts
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.16.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.16.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dry-auto_inject
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.0
33
+ version: 0.8.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.7.0
40
+ version: 0.8.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,20 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.7.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: dry-configurable
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.12.1
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.12.1
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: '1.17'
131
+ version: '2.2'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: '1.17'
138
+ version: '2.2'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rake
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -181,7 +195,6 @@ files:
181
195
  - ".travis.yml"
182
196
  - CHANGELOG.md
183
197
  - Gemfile
184
- - Gemfile.lock
185
198
  - LICENSE.txt
186
199
  - README.md
187
200
  - Rakefile
@@ -281,6 +294,7 @@ files:
281
294
  - lib/kuber_kit/core/templates/abstract_template.rb
282
295
  - lib/kuber_kit/core/templates/artifact_file.rb
283
296
  - lib/kuber_kit/core/templates/template_store.rb
297
+ - lib/kuber_kit/defaults.rb
284
298
  - lib/kuber_kit/env_file_reader/action_handler.rb
285
299
  - lib/kuber_kit/env_file_reader/env_file_parser.rb
286
300
  - lib/kuber_kit/env_file_reader/env_file_tempfile_creator.rb
@@ -362,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
376
  - !ruby/object:Gem::Version
363
377
  version: '0'
364
378
  requirements: []
365
- rubygems_version: 3.0.8
379
+ rubygems_version: 3.0.3.1
366
380
  signing_key:
367
381
  specification_version: 4
368
382
  summary: Docker Containers Build & Deployment
data/Gemfile.lock DELETED
@@ -1,84 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- kuber_kit (0.6.2)
5
- cli-ui
6
- contracts-lite
7
- dry-auto_inject (~> 0.7.0)
8
- dry-container (~> 0.7.2)
9
- net-ssh
10
- thor
11
- tty-prompt
12
-
13
- GEM
14
- remote: https://rubygems.org/
15
- specs:
16
- cli-ui (1.5.1)
17
- coderay (1.1.3)
18
- concurrent-ruby (1.1.9)
19
- contracts-lite (0.15.0)
20
- diff-lcs (1.4.4)
21
- docile (1.3.2)
22
- dry-auto_inject (0.7.0)
23
- dry-container (>= 0.3.4)
24
- dry-configurable (0.12.1)
25
- concurrent-ruby (~> 1.0)
26
- dry-core (~> 0.5, >= 0.5.0)
27
- dry-container (0.7.2)
28
- concurrent-ruby (~> 1.0)
29
- dry-configurable (~> 0.1, >= 0.1.3)
30
- dry-core (0.6.0)
31
- concurrent-ruby (~> 1.0)
32
- method_source (1.0.0)
33
- net-ssh (6.1.0)
34
- pastel (0.8.0)
35
- tty-color (~> 0.5)
36
- pry (0.13.1)
37
- coderay (~> 1.1)
38
- method_source (~> 1.0)
39
- rake (10.5.0)
40
- rspec (3.10.0)
41
- rspec-core (~> 3.10.0)
42
- rspec-expectations (~> 3.10.0)
43
- rspec-mocks (~> 3.10.0)
44
- rspec-core (3.10.0)
45
- rspec-support (~> 3.10.0)
46
- rspec-expectations (3.10.0)
47
- diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.10.0)
49
- rspec-mocks (3.10.0)
50
- diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.10.0)
52
- rspec-support (3.10.0)
53
- simplecov (0.20.0)
54
- docile (~> 1.1)
55
- simplecov-html (~> 0.11)
56
- simplecov_json_formatter (~> 0.1)
57
- simplecov-html (0.12.3)
58
- simplecov_json_formatter (0.1.2)
59
- thor (1.1.0)
60
- tty-color (0.6.0)
61
- tty-cursor (0.7.1)
62
- tty-prompt (0.23.1)
63
- pastel (~> 0.8)
64
- tty-reader (~> 0.8)
65
- tty-reader (0.9.0)
66
- tty-cursor (~> 0.7)
67
- tty-screen (~> 0.8)
68
- wisper (~> 2.0)
69
- tty-screen (0.8.1)
70
- wisper (2.0.1)
71
-
72
- PLATFORMS
73
- ruby
74
-
75
- DEPENDENCIES
76
- bundler (~> 1.17)
77
- kuber_kit!
78
- pry
79
- rake (~> 10.0)
80
- rspec (~> 3.0)
81
- simplecov
82
-
83
- BUNDLED WITH
84
- 1.17.3