kuber_kit 1.3.2 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -1
  3. data/README.md +2 -2
  4. data/kuber_kit.gemspec +1 -0
  5. data/lib/kuber_kit/artifacts_sync/artifact_updater.rb +19 -9
  6. data/lib/kuber_kit/artifacts_sync/strategies/abstract.rb +9 -0
  7. data/lib/kuber_kit/artifacts_sync/strategies/git_updater.rb +46 -0
  8. data/lib/kuber_kit/artifacts_sync/strategies/null_updater.rb +12 -0
  9. data/lib/kuber_kit/cli.rb +17 -0
  10. data/lib/kuber_kit/container.rb +8 -4
  11. data/lib/kuber_kit/core/artifacts/abstract_artifact.rb +4 -0
  12. data/lib/kuber_kit/core/artifacts/git.rb +6 -1
  13. data/lib/kuber_kit/core/artifacts/local.rb +4 -0
  14. data/lib/kuber_kit/core/context_helper/abstract_helper.rb +5 -0
  15. data/lib/kuber_kit/core/context_helper/base_helper.rb +1 -7
  16. data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +3 -1
  17. data/lib/kuber_kit/core/context_helper/local_context_helper.rb +14 -0
  18. data/lib/kuber_kit/core/context_helper/service_helper.rb +15 -1
  19. data/lib/kuber_kit/defaults.rb +4 -4
  20. data/lib/kuber_kit/image_compiler/image_builder.rb +1 -1
  21. data/lib/kuber_kit/service_reader/reader.rb +2 -10
  22. data/lib/kuber_kit/shell/commands/git_commands.rb +10 -0
  23. data/lib/kuber_kit/template_reader/reader.rb +1 -0
  24. data/lib/kuber_kit/template_reader/renderer.rb +17 -0
  25. data/lib/kuber_kit/template_reader/strategies/artifact_file.rb +1 -0
  26. data/lib/kuber_kit/version.rb +1 -1
  27. data/lib/kuber_kit.rb +9 -3
  28. metadata +22 -5
  29. data/lib/kuber_kit/artifacts_sync/abstract_artifact_resolver.rb +0 -5
  30. data/lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb +0 -31
  31. data/lib/kuber_kit/artifacts_sync/null_artifact_resolver.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3a577fb45bf9933ff2168b199459df8bd3801246ec999e53d2f314a5cd76ca4
4
- data.tar.gz: 50404be436a1821825e11109a9f34564b6cd162a0c7c8a20e27b023f55fcde9d
3
+ metadata.gz: f784985d9b293274a28f84bddcae4acafab7a06cf6c7d708bdb9edd7f8995a54
4
+ data.tar.gz: d3e54ad8fc2866405fa166f548c799b456c89c236d23e2359df49ea24e47666d
5
5
  SHA512:
6
- metadata.gz: e36744815c27471bbe4785cdaa83301b15080e15abd38a189a9ed06dbc38b6ec070a213018fca27e3b17ec61a24ca923461800aeb9ba5979cbaf909fcc90bbd5
7
- data.tar.gz: d7720f929d549261f430cb4599ba4131f3472200aa53125355a7215f8e06c27a872a5cb7fb51be15ea93a333b56d82d2d2dd114c311e0ae9436671cb48920e37
6
+ metadata.gz: 6620ef8a0095d7903141b21f08e51539d9f56974f41175ce90f4249bbbb54f0d10f05122709ec4d3a37455497a80645b48dc2aeade58bdd5ac4266e4a26b7a7c
7
+ data.tar.gz: 7e4883ff8f89860808b41efa4887f6bf217ed30622b7a480d70b9e840ac542757ae6e028181ea07dc1d3f25d40139878c0f21490a7b85de9683285b2419f38e9
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
- **1.3.1**
1
+ **1.3.4**
2
+ - Fix checking branch name in git artifact update
3
+ - Make LocalContextHelper compatible with ruby 3
4
+
5
+ **1.3.3**
6
+ - Support "partials" in the templates with "render" method.
7
+ - Cleanup artifacts after deployment if cache_result: false
8
+ - Improve fetching git artifact when branch name has changed
9
+
10
+ **1.3.2**
2
11
  - Added an ability to generate helm templates using `kit generate` command
3
12
 
4
13
  **1.3.1**
data/README.md CHANGED
@@ -19,8 +19,8 @@ Please install specific kuber_kit version, depending on Ruby version.
19
19
  | Ruby Version | KuberKit Version |
20
20
  | ------------ | ------------ |
21
21
  | 2.6 | 1.0.1 |
22
- | 2.7 | 1.1.5 |
23
- | > 3.0 | 1.2.6 |
22
+ | 2.7 | 1.1.6 |
23
+ | > 3.0 | 1.3.3 |
24
24
 
25
25
  ## Usage
26
26
 
data/kuber_kit.gemspec CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "cli-ui", '2.1.0'
37
37
  spec.add_dependency "net-ssh"
38
38
  spec.add_dependency "tty-prompt"
39
+ spec.add_dependency 'ed25519'
39
40
 
40
41
  spec.add_development_dependency "bundler", "~> 2.2"
41
42
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,27 +1,37 @@
1
1
  class KuberKit::ArtifactsSync::ArtifactUpdater
2
- ResolverNotFoundError = Class.new(KuberKit::NotFoundError)
2
+ StrategyNotFoundError = Class.new(KuberKit::NotFoundError)
3
3
 
4
4
  include KuberKit::Import[
5
5
  "ui"
6
6
  ]
7
7
 
8
- def use_resolver(artifact_resolver, artifact_class:)
9
- @@resolvers ||= {}
8
+ def use_strategy(strategy, artifact_class:)
9
+ @@strategies ||= {}
10
10
 
11
- if !artifact_resolver.is_a?(KuberKit::ArtifactsSync::AbstractArtifactResolver)
12
- raise ArgumentError.new("should be an instance of KuberKit::ArtifactsSync::AbstractArtifactResolver, got: #{artifact_resolver.inspect}")
11
+ if !strategy.is_a?(KuberKit::ArtifactsSync::Strategies::Abstract)
12
+ raise ArgumentError.new("should be an instance of KuberKit::ArtifactsSync::Strategies::Abstract, got: #{strategy.inspect}")
13
13
  end
14
14
 
15
- @@resolvers[artifact_class] = artifact_resolver
15
+ @@strategies[artifact_class] = strategy
16
16
  end
17
17
 
18
18
  def update(shell, artifact)
19
- resolver = @@resolvers[artifact.class]
19
+ strategy = @@strategies[artifact.class]
20
20
 
21
21
  ui.print_debug "ArtifactUpdater", "Updating artifact #{artifact.name.to_s.green}"
22
22
 
23
- raise ResolverNotFoundError, "Can't find resolver for artifact #{artifact}" if resolver.nil?
23
+ raise StrategyNotFoundError, "Can't find strategy for artifact #{artifact}" if strategy.nil?
24
24
 
25
- resolver.resolve(shell, artifact)
25
+ strategy.update(shell, artifact)
26
+ end
27
+
28
+ def cleanup(shell, artifact)
29
+ strategy = @@strategies[artifact.class]
30
+
31
+ ui.print_debug "ArtifactUpdater", "Cleaning artifact #{artifact.name.to_s.green}"
32
+
33
+ raise StrategyNotFoundError, "Can't find strategy for artifact #{artifact}" if strategy.nil?
34
+
35
+ strategy.cleanup(shell, artifact)
26
36
  end
27
37
  end
@@ -0,0 +1,9 @@
1
+ class KuberKit::ArtifactsSync::Strategies::Abstract
2
+ def update(shell, artifact)
3
+ raise KuberKit::NotImplementedError, "must be implemented"
4
+ end
5
+
6
+ def cleanup(shell, artifact)
7
+ raise KuberKit::NotImplementedError, "must be implemented"
8
+ end
9
+ end
@@ -0,0 +1,46 @@
1
+ class KuberKit::ArtifactsSync::Strategies::GitUpdater < KuberKit::ArtifactsSync::Strategies::Abstract
2
+
3
+ include KuberKit::Import[
4
+ "shell.git_commands",
5
+ "shell.bash_commands",
6
+ ]
7
+
8
+ Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Artifacts::Git => Any
9
+ def update(shell, artifact)
10
+ already_cloned = artifact_already_cloned?(
11
+ shell: shell,
12
+ repo_path: artifact.cloned_path,
13
+ artifact: artifact
14
+ )
15
+
16
+ if already_cloned
17
+ git_commands.force_pull_repo(shell,
18
+ path: artifact.cloned_path, branch: artifact.branch
19
+ )
20
+ else
21
+ git_commands.download_repo(shell,
22
+ remote_url: artifact.remote_url, path: artifact.cloned_path, branch: artifact.branch
23
+ )
24
+ end
25
+ end
26
+
27
+ Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Artifacts::Git => Any
28
+ def cleanup(shell, artifact)
29
+ bash_commands.rm_rf(shell, artifact.cloned_path)
30
+ end
31
+
32
+ private
33
+ def artifact_already_cloned?(shell:, repo_path:, artifact:)
34
+ target_remote_url = git_commands.get_remote_url(shell, repo_path)
35
+ if target_remote_url != artifact.remote_url
36
+ return false
37
+ end
38
+
39
+ target_branch = git_commands.get_branch_name(shell, repo_path)
40
+ if target_branch != artifact.branch.to_s
41
+ return false
42
+ end
43
+
44
+ return true
45
+ end
46
+ end
@@ -0,0 +1,12 @@
1
+ class KuberKit::ArtifactsSync::Strategies::NullUpdater < KuberKit::ArtifactsSync::Strategies::Abstract
2
+
3
+ Contract KuberKit::Shell::AbstractShell, Any => Any
4
+ def update(shell, artifact)
5
+ return true
6
+ end
7
+
8
+ Contract KuberKit::Shell::AbstractShell, Any => Any
9
+ def cleanup(shell, artifact)
10
+ return true
11
+ end
12
+ end
data/lib/kuber_kit/cli.rb CHANGED
@@ -24,6 +24,8 @@ class KuberKit::CLI < Thor
24
24
  action_result = KuberKit::Container['actions.image_compiler'].call(image_names, options)
25
25
  end
26
26
 
27
+ clean_artifacts(options)
28
+
27
29
  if action_result && action_result.succeeded?
28
30
  time = (Time.now.to_i - started_at)
29
31
  print_result("Image compilation finished! (#{time}s)", result: {
@@ -64,6 +66,8 @@ class KuberKit::CLI < Thor
64
66
  )
65
67
  end
66
68
 
69
+ clean_artifacts(options)
70
+
67
71
  if action_result && action_result.succeeded?
68
72
  time = (Time.now.to_i - started_at)
69
73
  print_result("Service deployment finished! (#{time}s)", result: {
@@ -230,4 +234,17 @@ class KuberKit::CLI < Thor
230
234
  def print_result(message, data = {})
231
235
  KuberKit::Container['ui'].print_result(message, data)
232
236
  end
237
+
238
+ def clean_artifacts(options)
239
+ artifacts = KuberKit.current_configuration.artifacts.values
240
+ artifacts_to_clean = artifacts.select(&:cleanup_needed?)
241
+
242
+ return unless artifacts_to_clean.any?
243
+
244
+ artifacts_to_clean.each do |artifact|
245
+ KuberKit::Container['artifacts_sync.artifact_updater'].cleanup(
246
+ KuberKit::Container['shell.local_shell'], artifact
247
+ )
248
+ end
249
+ end
233
250
  end
@@ -237,12 +237,12 @@ class KuberKit::Container
237
237
  KuberKit::ArtifactsSync::ArtifactUpdater.new
238
238
  end
239
239
 
240
- register "artifacts_sync.git_artifact_resolver" do
241
- KuberKit::ArtifactsSync::GitArtifactResolver.new
240
+ register "artifacts_sync.strategies.git_updater" do
241
+ KuberKit::ArtifactsSync::Strategies::GitUpdater.new
242
242
  end
243
243
 
244
- register "artifacts_sync.null_artifact_resolver" do
245
- KuberKit::ArtifactsSync::NullArtifactResolver.new
244
+ register "artifacts_sync.strategies.null_updater" do
245
+ KuberKit::ArtifactsSync::Strategies::NullUpdater.new
246
246
  end
247
247
 
248
248
  register "env_file_reader.action_handler" do
@@ -277,6 +277,10 @@ class KuberKit::Container
277
277
  KuberKit::TemplateReader::Reader.new
278
278
  end
279
279
 
280
+ register "template_reader.renderer" do
281
+ KuberKit::TemplateReader::Renderer.new
282
+ end
283
+
280
284
  register "template_reader.strategies.artifact_file" do
281
285
  KuberKit::TemplateReader::Strategies::ArtifactFile.new
282
286
  end
@@ -14,4 +14,8 @@ class KuberKit::Core::Artifacts::AbstractArtifact
14
14
  def sync_description
15
15
  raise KuberKit::NotImplementedError, "must be implemented"
16
16
  end
17
+
18
+ def cleanup_needed?
19
+ raise KuberKit::NotImplementedError, "must be implemented"
20
+ end
17
21
  end
@@ -5,12 +5,13 @@ class KuberKit::Core::Artifacts::Git < KuberKit::Core::Artifacts::AbstractArtifa
5
5
  DEFAULT_REMOTE_NAME = "origin"
6
6
  DEFAULT_BRANCH = "master"
7
7
 
8
- def setup(remote_url:, remote_name: DEFAULT_REMOTE_NAME, branch: DEFAULT_BRANCH, clone_path: nil, ssh_key: DEFAULT_SSH_KEY)
8
+ def setup(remote_url:, remote_name: DEFAULT_REMOTE_NAME, branch: DEFAULT_BRANCH, clone_path: nil, ssh_key: DEFAULT_SSH_KEY, cache_result: true)
9
9
  @remote_name = remote_name
10
10
  @remote_url = remote_url
11
11
  @branch = branch
12
12
  @clone_path = clone_path
13
13
  @ssh_key = ssh_key
14
+ @cache_result = cache_result
14
15
  self
15
16
  end
16
17
 
@@ -23,4 +24,8 @@ class KuberKit::Core::Artifacts::Git < KuberKit::Core::Artifacts::AbstractArtifa
23
24
  def sync_description
24
25
  "#{remote_url}:#{branch}"
25
26
  end
27
+
28
+ def cleanup_needed?
29
+ !@cache_result
30
+ end
26
31
  end
@@ -15,4 +15,8 @@ class KuberKit::Core::Artifacts::Local < KuberKit::Core::Artifacts::AbstractArti
15
15
  def sync_description
16
16
  "local"
17
17
  end
18
+
19
+ def cleanup_needed?
20
+ false
21
+ end
18
22
  end
@@ -0,0 +1,5 @@
1
+ class KuberKit::Core::ContextHelper::AbstractHelper
2
+ def get_binding
3
+ binding
4
+ end
5
+ end
@@ -1,6 +1,4 @@
1
- class KuberKit::Core::ContextHelper::BaseHelper
2
- CONTRACT = RespondTo[:get_binding]
3
-
1
+ class KuberKit::Core::ContextHelper::BaseHelper < KuberKit::Core::ContextHelper::AbstractHelper
4
2
  attr_reader :shell, :artifact_store, :image_store, :env_file_reader
5
3
 
6
4
  def initialize(image_store:, artifact_store:, shell:, env_file_reader:)
@@ -39,8 +37,4 @@ class KuberKit::Core::ContextHelper::BaseHelper
39
37
  end
40
38
  global_build_vars
41
39
  end
42
-
43
- def get_binding
44
- binding
45
- end
46
40
  end
@@ -2,7 +2,8 @@ class KuberKit::Core::ContextHelper::ContextHelperFactory
2
2
  include KuberKit::Import[
3
3
  "core.image_store",
4
4
  "core.artifact_store",
5
- env_file_reader: "env_file_reader.action_handler"
5
+ template_renderer: "template_reader.renderer",
6
+ env_file_reader: "env_file_reader.action_handler"
6
7
  ]
7
8
 
8
9
  def build_image_context(shell, image)
@@ -22,6 +23,7 @@ class KuberKit::Core::ContextHelper::ContextHelperFactory
22
23
  shell: shell,
23
24
  env_file_reader: env_file_reader,
24
25
  service: service,
26
+ template_renderer: template_renderer
25
27
  )
26
28
  end
27
29
  end
@@ -0,0 +1,14 @@
1
+ class KuberKit::Core::ContextHelper::LocalContextHelper < KuberKit::Core::ContextHelper::AbstractHelper
2
+ def initialize(parent_context_helper:, variables:)
3
+ @parent_context_helper = parent_context_helper
4
+ @variables = variables
5
+ end
6
+
7
+ def method_missing(method_name, *args, **kwargs, &block)
8
+ if @variables.has_key?(method_name)
9
+ @variables[method_name]
10
+ else
11
+ @parent_context_helper.send(method_name, *args, **kwargs, &block)
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  class KuberKit::Core::ContextHelper::ServiceHelper < KuberKit::Core::ContextHelper::BaseHelper
2
- def initialize(image_store:, artifact_store:, shell:, env_file_reader:, service:)
2
+ def initialize(image_store:, artifact_store:, shell:, env_file_reader:, service:, template_renderer:)
3
3
  super(
4
4
  image_store: image_store,
5
5
  artifact_store: artifact_store,
@@ -7,6 +7,7 @@ class KuberKit::Core::ContextHelper::ServiceHelper < KuberKit::Core::ContextHelp
7
7
  env_file_reader: env_file_reader
8
8
  )
9
9
  @service = service
10
+ @template_renderer = template_renderer
10
11
  end
11
12
 
12
13
  def service_name
@@ -20,4 +21,17 @@ class KuberKit::Core::ContextHelper::ServiceHelper < KuberKit::Core::ContextHelp
20
21
  def attribute(attribute_name, default: nil)
21
22
  @service.attribute(attribute_name, default: default)
22
23
  end
24
+
25
+ Contract Maybe[String, Symbol], Hash => String
26
+ def render(template_name, variables = {})
27
+ context_helper = KuberKit::Core::ContextHelper::LocalContextHelper.new(
28
+ parent_context_helper: self,
29
+ variables: variables
30
+ )
31
+ @template_renderer.call(shell, template_name.to_sym, context_helper: context_helper)
32
+ end
33
+
34
+ def method_missing(m, *args, &block)
35
+ raise("Unknown variable: #{m} while rendering '#{service_name}' with '#{@service.template_name}' template.")
36
+ end
23
37
  end
@@ -7,12 +7,12 @@ class KuberKit::Defaults
7
7
  end
8
8
 
9
9
  def init!
10
- container["artifacts_sync.artifact_updater"].use_resolver(
11
- container["artifacts_sync.git_artifact_resolver"],
10
+ container["artifacts_sync.artifact_updater"].use_strategy(
11
+ container["artifacts_sync.strategies.git_updater"],
12
12
  artifact_class: KuberKit::Core::Artifacts::Git
13
13
  )
14
- container["artifacts_sync.artifact_updater"].use_resolver(
15
- container["artifacts_sync.null_artifact_resolver"],
14
+ container["artifacts_sync.artifact_updater"].use_strategy(
15
+ container["artifacts_sync.strategies.null_updater"],
16
16
  artifact_class: KuberKit::Core::Artifacts::Local
17
17
  )
18
18
  container["env_file_reader.reader"].use_reader(
@@ -5,7 +5,7 @@ class KuberKit::ImageCompiler::ImageBuilder
5
5
  ]
6
6
 
7
7
  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Image, String, KeywordArgs[
8
- context_helper: Maybe[KuberKit::Core::ContextHelper::BaseHelper::CONTRACT]
8
+ context_helper: Maybe[KuberKit::Core::ContextHelper::AbstractHelper]
9
9
  ] => Any
10
10
  def build(shell, image, build_dir, context_helper: nil)
11
11
  image.before_build_callback.call(context_helper, build_dir) if image.before_build_callback
@@ -1,9 +1,7 @@
1
1
  class KuberKit::ServiceReader::Reader
2
2
  include KuberKit::Import[
3
- "core.template_store",
4
3
  "core.context_helper_factory",
5
- "template_reader.reader",
6
- "preprocessing.text_preprocessor"
4
+ "template_reader.renderer"
7
5
  ]
8
6
 
9
7
  AttributeNotSetError = Class.new(KuberKit::Error)
@@ -14,14 +12,8 @@ class KuberKit::ServiceReader::Reader
14
12
  raise AttributeNotSetError, "Please set template for service using #template method"
15
13
  end
16
14
 
17
- template = template_store.get(service.template_name)
18
-
19
15
  context_helper = context_helper_factory.build_service_context(shell, service)
20
16
 
21
- template = reader.read(shell, template)
22
-
23
- result = text_preprocessor.compile(template, context_helper: context_helper)
24
-
25
- result
17
+ renderer.call(shell, service.template_name, context_helper: context_helper)
26
18
  end
27
19
  end
@@ -8,6 +8,15 @@ class KuberKit::Shell::Commands::GitCommands
8
8
  return nil
9
9
  end
10
10
 
11
+ def get_branch_name(shell, git_repo_path, remote_name: "origin")
12
+ shell.exec!([
13
+ "cd #{git_repo_path}",
14
+ "git rev-parse --abbrev-ref HEAD",
15
+ ].join(" && "), merge_stderr: true)
16
+ rescue KuberKit::Shell::AbstractShell::ShellError
17
+ return nil
18
+ end
19
+
11
20
  def get_version_hash(shell, git_repo_path)
12
21
  shell.exec!([
13
22
  "cd #{git_repo_path}",
@@ -28,6 +37,7 @@ class KuberKit::Shell::Commands::GitCommands
28
37
  "cd #{path}",
29
38
  "git add .",
30
39
  "git reset HEAD --hard",
40
+ "git fetch origin #{branch}",
31
41
  "git checkout #{branch}",
32
42
  "git reset --hard '@{u}'",
33
43
  "git pull --force",
@@ -11,6 +11,7 @@ class KuberKit::TemplateReader::Reader
11
11
  @@readers[template_class] = template_reader
12
12
  end
13
13
 
14
+ Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Templates::AbstractTemplate => String
14
15
  def read(shell, template)
15
16
  reader = @@readers[template.class]
16
17
 
@@ -0,0 +1,17 @@
1
+ class KuberKit::TemplateReader::Renderer
2
+ include KuberKit::Import[
3
+ "core.template_store",
4
+ "preprocessing.text_preprocessor",
5
+ template_reader: "template_reader.reader"
6
+ ]
7
+
8
+
9
+ Contract KuberKit::Shell::AbstractShell, Symbol, KeywordArgs[
10
+ context_helper: KuberKit::Core::ContextHelper::AbstractHelper
11
+ ] => String
12
+ def call(shell, template_name, context_helper:)
13
+ template = template_store.get(template_name)
14
+ template_text = template_reader.read(shell, template)
15
+ text_preprocessor.compile(template_text, context_helper: context_helper)
16
+ end
17
+ end
@@ -3,6 +3,7 @@ class KuberKit::TemplateReader::Strategies::ArtifactFile < KuberKit::TemplateRea
3
3
  "core.artifact_store"
4
4
  ]
5
5
 
6
+ Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Templates::AbstractTemplate => String
6
7
  def read(shell, template)
7
8
  artifact = artifact_store.get(template.artifact_name)
8
9
 
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.4"
3
3
  end
data/lib/kuber_kit.rb CHANGED
@@ -61,11 +61,13 @@ module KuberKit
61
61
  end
62
62
 
63
63
  module ContextHelper
64
+ autoload :AbstractHelper, 'core/context_helper/abstract_helper'
64
65
  autoload :BaseHelper, 'core/context_helper/base_helper'
65
66
  autoload :ImageHelper, 'core/context_helper/image_helper'
66
67
  autoload :ServiceHelper, 'core/context_helper/service_helper'
67
68
  autoload :ContextHelperFactory, 'core/context_helper/context_helper_factory'
68
69
  autoload :ContextVars, 'core/context_helper/context_vars'
70
+ autoload :LocalContextHelper, 'core/context_helper/local_context_helper'
69
71
  end
70
72
 
71
73
  module Registries
@@ -125,10 +127,13 @@ module KuberKit
125
127
  end
126
128
 
127
129
  module ArtifactsSync
128
- autoload :AbstractArtifactResolver, 'artifacts_sync/abstract_artifact_resolver'
129
130
  autoload :ArtifactUpdater, 'artifacts_sync/artifact_updater'
130
- autoload :GitArtifactResolver, 'artifacts_sync/git_artifact_resolver'
131
- autoload :NullArtifactResolver, 'artifacts_sync/null_artifact_resolver'
131
+
132
+ module Strategies
133
+ autoload :Abstract, 'artifacts_sync/strategies/abstract'
134
+ autoload :GitUpdater, 'artifacts_sync/strategies/git_updater'
135
+ autoload :NullUpdater, 'artifacts_sync/strategies/null_updater'
136
+ end
132
137
  end
133
138
 
134
139
  module EnvFileReader
@@ -147,6 +152,7 @@ module KuberKit
147
152
  module TemplateReader
148
153
  autoload :ActionHandler, 'template_reader/action_handler'
149
154
  autoload :Reader, 'template_reader/reader'
155
+ autoload :Renderer, 'template_reader/renderer'
150
156
 
151
157
  module Strategies
152
158
  autoload :Abstract, 'template_reader/strategies/abstract'
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: 1.3.2
4
+ version: 1.3.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: 2023-09-25 00:00:00.000000000 Z
11
+ date: 2023-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: ed25519
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: bundler
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -263,10 +277,10 @@ files:
263
277
  - lib/kuber_kit/actions/service_reader.rb
264
278
  - lib/kuber_kit/actions/shell_launcher.rb
265
279
  - lib/kuber_kit/actions/template_reader.rb
266
- - lib/kuber_kit/artifacts_sync/abstract_artifact_resolver.rb
267
280
  - lib/kuber_kit/artifacts_sync/artifact_updater.rb
268
- - lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
269
- - lib/kuber_kit/artifacts_sync/null_artifact_resolver.rb
281
+ - lib/kuber_kit/artifacts_sync/strategies/abstract.rb
282
+ - lib/kuber_kit/artifacts_sync/strategies/git_updater.rb
283
+ - lib/kuber_kit/artifacts_sync/strategies/null_updater.rb
270
284
  - lib/kuber_kit/cli.rb
271
285
  - lib/kuber_kit/configs.rb
272
286
  - lib/kuber_kit/container.rb
@@ -284,10 +298,12 @@ files:
284
298
  - lib/kuber_kit/core/configuration_definition_factory.rb
285
299
  - lib/kuber_kit/core/configuration_factory.rb
286
300
  - lib/kuber_kit/core/configuration_store.rb
301
+ - lib/kuber_kit/core/context_helper/abstract_helper.rb
287
302
  - lib/kuber_kit/core/context_helper/base_helper.rb
288
303
  - lib/kuber_kit/core/context_helper/context_helper_factory.rb
289
304
  - lib/kuber_kit/core/context_helper/context_vars.rb
290
305
  - lib/kuber_kit/core/context_helper/image_helper.rb
306
+ - lib/kuber_kit/core/context_helper/local_context_helper.rb
291
307
  - lib/kuber_kit/core/context_helper/service_helper.rb
292
308
  - lib/kuber_kit/core/dependencies/abstract_dependency_resolver.rb
293
309
  - lib/kuber_kit/core/env_files/abstract_env_file.rb
@@ -373,6 +389,7 @@ files:
373
389
  - lib/kuber_kit/shell_launcher/strategies/kubernetes.rb
374
390
  - lib/kuber_kit/template_reader/action_handler.rb
375
391
  - lib/kuber_kit/template_reader/reader.rb
392
+ - lib/kuber_kit/template_reader/renderer.rb
376
393
  - lib/kuber_kit/template_reader/strategies/abstract.rb
377
394
  - lib/kuber_kit/template_reader/strategies/artifact_file.rb
378
395
  - lib/kuber_kit/tools/build_dir_cleaner.rb
@@ -1,5 +0,0 @@
1
- class KuberKit::ArtifactsSync::AbstractArtifactResolver
2
- def resolve(shell, artifact)
3
- raise KuberKit::NotImplementedError, "must be implemented"
4
- end
5
- end
@@ -1,31 +0,0 @@
1
- class KuberKit::ArtifactsSync::GitArtifactResolver < KuberKit::ArtifactsSync::AbstractArtifactResolver
2
-
3
- include KuberKit::Import[
4
- "shell.git_commands",
5
- ]
6
-
7
- Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Artifacts::Git => Any
8
- def resolve(shell, artifact)
9
- already_cloned = artifact_already_cloned?(
10
- shell: shell,
11
- target_path: artifact.cloned_path,
12
- remote_url: artifact.remote_url,
13
- )
14
-
15
- if already_cloned
16
- git_commands.force_pull_repo(shell,
17
- path: artifact.cloned_path, branch: artifact.branch
18
- )
19
- else
20
- git_commands.download_repo(shell,
21
- remote_url: artifact.remote_url, path: artifact.cloned_path, branch: artifact.branch
22
- )
23
- end
24
- end
25
-
26
- private
27
- def artifact_already_cloned?(shell:, target_path:, remote_url:)
28
- target_remote_url = git_commands.get_remote_url(shell, target_path)
29
- target_remote_url == remote_url
30
- end
31
- end
@@ -1,7 +0,0 @@
1
- class KuberKit::ArtifactsSync::NullArtifactResolver < KuberKit::ArtifactsSync::AbstractArtifactResolver
2
-
3
- Contract KuberKit::Shell::AbstractShell, Any => Any
4
- def resolve(shell, artifact)
5
- return true
6
- end
7
- end