kuber_kit 1.1.8 → 1.2.0

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rspec.yml +1 -1
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +0 -48
  5. data/README.md +2 -2
  6. data/kuber_kit.gemspec +3 -3
  7. data/lib/kuber_kit/actions/configuration_loader.rb +3 -13
  8. data/lib/kuber_kit/actions/kubectl_attacher.rb +4 -7
  9. data/lib/kuber_kit/actions/kubectl_get.rb +3 -3
  10. data/lib/kuber_kit/actions/kubectl_logs.rb +4 -7
  11. data/lib/kuber_kit/actions/service_deployer.rb +27 -40
  12. data/lib/kuber_kit/artifacts_sync/abstract_artifact_resolver.rb +5 -0
  13. data/lib/kuber_kit/artifacts_sync/artifact_updater.rb +9 -19
  14. data/lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb +31 -0
  15. data/lib/kuber_kit/artifacts_sync/null_artifact_resolver.rb +7 -0
  16. data/lib/kuber_kit/cli.rb +2 -36
  17. data/lib/kuber_kit/configs.rb +1 -4
  18. data/lib/kuber_kit/container.rb +4 -28
  19. data/lib/kuber_kit/core/artifacts/abstract_artifact.rb +0 -8
  20. data/lib/kuber_kit/core/artifacts/git.rb +1 -10
  21. data/lib/kuber_kit/core/artifacts/local.rb +0 -8
  22. data/lib/kuber_kit/core/configuration.rb +6 -10
  23. data/lib/kuber_kit/core/configuration_definition.rb +9 -30
  24. data/lib/kuber_kit/core/configuration_factory.rb +1 -3
  25. data/lib/kuber_kit/core/context_helper/base_helper.rb +7 -1
  26. data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +1 -3
  27. data/lib/kuber_kit/core/context_helper/context_vars.rb +19 -33
  28. data/lib/kuber_kit/core/context_helper/service_helper.rb +1 -15
  29. data/lib/kuber_kit/core/dependencies/abstract_dependency_resolver.rb +0 -7
  30. data/lib/kuber_kit/core/service.rb +5 -8
  31. data/lib/kuber_kit/core/service_definition.rb +4 -16
  32. data/lib/kuber_kit/core/service_factory.rb +1 -2
  33. data/lib/kuber_kit/defaults.rb +4 -13
  34. data/lib/kuber_kit/image_compiler/image_builder.rb +1 -1
  35. data/lib/kuber_kit/service_deployer/service_dependency_resolver.rb +1 -1
  36. data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +2 -8
  37. data/lib/kuber_kit/service_reader/reader.rb +10 -2
  38. data/lib/kuber_kit/shell/commands/bash_commands.rb +6 -6
  39. data/lib/kuber_kit/shell/commands/docker_commands.rb +5 -5
  40. data/lib/kuber_kit/shell/commands/docker_compose_commands.rb +1 -1
  41. data/lib/kuber_kit/shell/commands/git_commands.rb +12 -19
  42. data/lib/kuber_kit/shell/commands/kubectl_commands.rb +4 -5
  43. data/lib/kuber_kit/shell/commands/rsync_commands.rb +1 -1
  44. data/lib/kuber_kit/shell/commands/system_commands.rb +1 -1
  45. data/lib/kuber_kit/shell/local_shell.rb +8 -12
  46. data/lib/kuber_kit/shell/ssh_session.rb +1 -5
  47. data/lib/kuber_kit/shell/ssh_shell.rb +2 -2
  48. data/lib/kuber_kit/shell_launcher/strategies/kubernetes.rb +1 -10
  49. data/lib/kuber_kit/template_reader/reader.rb +0 -1
  50. data/lib/kuber_kit/template_reader/strategies/artifact_file.rb +0 -1
  51. data/lib/kuber_kit/tools/logger_factory.rb +1 -1
  52. data/lib/kuber_kit/version.rb +1 -1
  53. data/lib/kuber_kit.rb +3 -23
  54. metadata +13 -24
  55. data/lib/kuber_kit/actions/service_generator.rb +0 -20
  56. data/lib/kuber_kit/artifacts_sync/strategies/abstract.rb +0 -9
  57. data/lib/kuber_kit/artifacts_sync/strategies/git_updater.rb +0 -46
  58. data/lib/kuber_kit/artifacts_sync/strategies/null_updater.rb +0 -12
  59. data/lib/kuber_kit/core/context_helper/abstract_helper.rb +0 -5
  60. data/lib/kuber_kit/core/context_helper/local_context_helper.rb +0 -14
  61. data/lib/kuber_kit/service_deployer/strategies/helm.rb +0 -41
  62. data/lib/kuber_kit/service_generator/action_handler.rb +0 -16
  63. data/lib/kuber_kit/service_generator/generator.rb +0 -26
  64. data/lib/kuber_kit/service_generator/strategies/abstract.rb +0 -5
  65. data/lib/kuber_kit/service_generator/strategies/helm.rb +0 -33
  66. data/lib/kuber_kit/service_generator/strategy_detector.rb +0 -6
  67. data/lib/kuber_kit/shell/commands/helm_commands.rb +0 -42
  68. data/lib/kuber_kit/template_reader/renderer.rb +0 -17
@@ -1,43 +1,36 @@
1
1
  class KuberKit::Shell::Commands::GitCommands
2
2
  def get_remote_url(shell, git_repo_path, remote_name: "origin")
3
- shell.exec!([
3
+ shell.exec! [
4
4
  "cd #{git_repo_path}",
5
5
  "git config --get remote.#{remote_name}.url",
6
- ].join(" && "), merge_stderr: true)
7
- rescue KuberKit::Shell::AbstractShell::ShellError
8
- return nil
9
- end
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)
6
+ ].join(" && ")
16
7
  rescue KuberKit::Shell::AbstractShell::ShellError
17
8
  return nil
18
9
  end
19
10
 
20
11
  def get_version_hash(shell, git_repo_path)
21
- shell.exec!([
12
+ shell.exec! [
22
13
  "cd #{git_repo_path}",
23
14
  "git rev-parse --short HEAD",
24
- ].join(" && "), merge_stderr: true)
15
+ ].join(" && ")
25
16
  end
26
17
 
27
18
  def download_repo(shell, remote_url:, path:, branch:)
28
- shell.exec!([
19
+ shell.exec! [
29
20
  "rm -rf #{path}",
30
21
  "mkdir -p #{path}",
31
22
  "git clone -b #{branch} --depth 1 #{remote_url} #{path}",
32
- ].join(" && "), merge_stderr: true)
23
+ ].join(" && ")
33
24
  end
34
25
 
35
26
  def force_pull_repo(shell, path:, branch:)
36
- shell.exec!([
27
+ shell.exec! [
37
28
  "cd #{path}",
38
29
  "git add .",
39
- "git fetch origin #{branch}",
40
- "git reset --hard '@{u}'"
41
- ].join(" && "), merge_stderr: true)
30
+ "git reset HEAD --hard",
31
+ "git checkout #{branch}",
32
+ "git reset --hard '@{u}'",
33
+ "git pull --force",
34
+ ].join(" && ")
42
35
  end
43
36
  end
@@ -10,8 +10,8 @@ class KuberKit::Shell::Commands::KubectlCommands
10
10
  kubeconfig_path: Maybe[Or[
11
11
  String, KuberKit::Core::ArtifactPath
12
12
  ]],
13
- namespace: Maybe[Or[Symbol, String]],
14
- interactive: Optional[Bool],
13
+ namespace: Maybe[Or[Symbol, String]],
14
+ interactive: Optional[Bool],
15
15
  ] => Any
16
16
  def kubectl_run(shell, command_list, kubeconfig_path: nil, namespace: nil, interactive: false)
17
17
  command_parts = []
@@ -39,9 +39,8 @@ class KuberKit::Shell::Commands::KubectlCommands
39
39
  end
40
40
  end
41
41
 
42
- def apply_file(shell, file_path, kubeconfig_path: nil, namespace: nil, apply_command: nil)
43
- apply_command ||= "apply"
44
- kubectl_run(shell, "#{apply_command} -f #{file_path}", kubeconfig_path: kubeconfig_path, namespace: namespace)
42
+ def apply_file(shell, file_path, kubeconfig_path: nil, namespace: nil)
43
+ kubectl_run(shell, "apply -f #{file_path}", kubeconfig_path: kubeconfig_path, namespace: namespace)
45
44
  end
46
45
 
47
46
  def exec(shell, pod_name, command, args: nil, kubeconfig_path: nil, interactive: false, namespace: nil, entrypoint: nil)
@@ -22,7 +22,7 @@ class KuberKit::Shell::Commands::RsyncCommands
22
22
  args << "--delete"
23
23
  end
24
24
 
25
- shell.exec!(%Q{rsync -a #{args.join(' ')}}, merge_stderr: true)
25
+ shell.exec!(%Q{rsync -a #{args.join(' ')}})
26
26
  end
27
27
 
28
28
  private
@@ -2,7 +2,7 @@ class KuberKit::Shell::Commands::SystemCommands
2
2
  def kill_process(shell, pid)
3
3
  # we need to use kill command directly sometimes,
4
4
  # because Process.kill doesn't kill processes created by system() call
5
- shell.exec!("kill -9 #{pid}", merge_stderr: true)
5
+ shell.exec!("kill -9 #{pid}")
6
6
  true
7
7
  rescue
8
8
  false
@@ -9,9 +9,7 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
9
9
  "ui",
10
10
  ]
11
11
 
12
- # @merge_stderr: Merge STDERR to the resulting stream. Could be helpful, if we don't want it printed to STDERR.
13
- # Should be false, if we want to read & use the result of the command.
14
- def exec!(command, log_command: true, merge_stderr: false)
12
+ def exec!(command, log_command: true)
15
13
  command_number = command_counter.get_number.to_s.rjust(2, "0")
16
14
 
17
15
  if log_command
@@ -19,9 +17,7 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
19
17
  end
20
18
 
21
19
  result = nil
22
-
23
- options = merge_stderr ? {err: [:child, :out]} : {}
24
- IO.popen(wrap_command_with_pid(command), **options) do |io|
20
+ IO.popen(wrap_command_with_pid(command), err: [:child, :out]) do |io|
25
21
  result = io.read.chomp.strip
26
22
  end
27
23
 
@@ -92,21 +88,21 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
92
88
  end
93
89
 
94
90
  def delete(file_path)
95
- exec!("rm #{file_path}", merge_stderr: true)
91
+ exec!("rm #{file_path}")
96
92
  end
97
93
 
98
94
  def file_exists?(file_path)
99
- exec!("test -f #{file_path} && echo 'true' || echo 'false'", log_command: false, merge_stderr: true) == 'true'
95
+ exec!("test -f #{file_path} && echo 'true' || echo 'false'", log_command: false) == 'true'
100
96
  end
101
97
 
102
98
  def dir_exists?(dir_path)
103
- exec!("test -d #{dir_path} && echo 'true' || echo 'false'", log_command: false, merge_stderr: true) == 'true'
99
+ exec!("test -d #{dir_path} && echo 'true' || echo 'false'", log_command: false) == 'true'
104
100
  end
105
101
 
106
102
  def recursive_list_files(path, name: nil)
107
103
  command = %Q{find -L #{path} -type f}
108
104
  command += " -name '#{name}'" if name
109
- exec!(command, merge_stderr: true).split(/[\r\n]+/)
105
+ exec!(command).split(/[\r\n]+/)
110
106
  rescue => e
111
107
  if e.message.include?("No such file or directory")
112
108
  raise DirNotFoundError.new("Dir not found: #{path}")
@@ -117,7 +113,7 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
117
113
 
118
114
  def list_dirs(path)
119
115
  command = %Q{find -L #{path} -maxdepth 0 -type d}
120
- exec!(command, merge_stderr: true).split(/[\r\n]+/)
116
+ exec!(command).split(/[\r\n]+/)
121
117
  rescue => e
122
118
  if e.message.include?("No such file or directory")
123
119
  raise DirNotFoundError.new("Dir not found: #{path}")
@@ -138,7 +134,7 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
138
134
  def ensure_directory_exists(file_path)
139
135
  dir_path = File.dirname(file_path)
140
136
 
141
- unless Dir.exist?(dir_path)
137
+ unless Dir.exists?(dir_path)
142
138
  FileUtils.mkdir_p(dir_path)
143
139
  end
144
140
  end
@@ -22,7 +22,7 @@ class KuberKit::Shell::SshSession
22
22
  @session = nil
23
23
  end
24
24
 
25
- def exec!(command, merge_stderr: false)
25
+ def exec!(command)
26
26
  stdout_data = ''
27
27
  stderr_data = ''
28
28
  exit_code = nil
@@ -38,10 +38,6 @@ class KuberKit::Shell::SshSession
38
38
 
39
39
  channel.on_extended_data do |ch,type,data|
40
40
  stderr_data += data
41
-
42
- if merge_stderr
43
- stdout_data += data
44
- end
45
41
  end
46
42
 
47
43
  channel.on_request('exit-status') do |ch,data|
@@ -20,14 +20,14 @@ class KuberKit::Shell::SshShell < KuberKit::Shell::LocalShell
20
20
  @ssh_session.disconnect if @ssh_session
21
21
  end
22
22
 
23
- def exec!(command, log_command: true, merge_stderr: false)
23
+ def exec!(command, log_command: true)
24
24
  command_number = command_counter.get_number.to_s.rjust(2, "0")
25
25
 
26
26
  if log_command
27
27
  ui.print_debug("SshShell", "#{ssh_session.host.green} > Execute: [#{command_number}]: #{command.to_s.cyan}")
28
28
  end
29
29
 
30
- result = ssh_session.exec!(wrap_command_with_pid(command), merge_stderr: merge_stderr)
30
+ result = ssh_session.exec!(wrap_command_with_pid(command))
31
31
 
32
32
  if result && result != "" && log_command
33
33
  ui.print_debug("SshShell", "#{ssh_session.host.green} > Finished [#{command_number}] with result: \n#{result.grey}")
@@ -17,15 +17,6 @@ class KuberKit::ShellLauncher::Strategies::Kubernetes < KuberKit::ShellLauncher:
17
17
  kubectl_commands.set_namespace(shell, deployer_namespace, kubeconfig_path: kubeconfig_path)
18
18
  end
19
19
 
20
- env_vars = [
21
- "KUBECONFIG=#{kubeconfig_path}",
22
- "KUBER_KIT_SHELL_CONFIGURATION=#{KuberKit.current_configuration.name}"
23
- ]
24
-
25
- if configs.shell_launcher_sets_configration
26
- env_vars << "KUBER_KIT_CONFIGURATION=#{KuberKit.current_configuration.name}"
27
- end
28
-
29
- shell.replace!(env: env_vars)
20
+ shell.replace!(env: ["KUBECONFIG=#{kubeconfig_path}", "KUBER_KIT_SHELL_CONFIGURATION=#{KuberKit.current_configuration.name}"])
30
21
  end
31
22
  end
@@ -11,7 +11,6 @@ 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
15
14
  def read(shell, template)
16
15
  reader = @@readers[template.class]
17
16
 
@@ -3,7 +3,6 @@ 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
7
6
  def read(shell, template)
8
7
  artifact = artifact_store.get(template.artifact_name)
9
8
 
@@ -45,7 +45,7 @@ class KuberKit::Tools::LoggerFactory
45
45
  private
46
46
  def prepare_log_file(file_path)
47
47
  dir_path = File.dirname(file_path)
48
- unless Dir.exist?(dir_path)
48
+ unless Dir.exists?(dir_path)
49
49
  FileUtils.mkdir_p(dir_path)
50
50
  end
51
51
  FileUtils.touch(file_path)
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "1.1.8"
2
+ VERSION = "1.2.0"
3
3
  end
data/lib/kuber_kit.rb CHANGED
@@ -61,13 +61,11 @@ module KuberKit
61
61
  end
62
62
 
63
63
  module ContextHelper
64
- autoload :AbstractHelper, 'core/context_helper/abstract_helper'
65
64
  autoload :BaseHelper, 'core/context_helper/base_helper'
66
65
  autoload :ImageHelper, 'core/context_helper/image_helper'
67
66
  autoload :ServiceHelper, 'core/context_helper/service_helper'
68
67
  autoload :ContextHelperFactory, 'core/context_helper/context_helper_factory'
69
68
  autoload :ContextVars, 'core/context_helper/context_vars'
70
- autoload :LocalContextHelper, 'core/context_helper/local_context_helper'
71
69
  end
72
70
 
73
71
  module Registries
@@ -106,7 +104,6 @@ module KuberKit
106
104
  autoload :RsyncCommands, 'shell/commands/rsync_commands'
107
105
  autoload :KubectlCommands, 'shell/commands/kubectl_commands'
108
106
  autoload :SystemCommands, 'shell/commands/system_commands'
109
- autoload :HelmCommands, 'shell/commands/helm_commands'
110
107
  end
111
108
  end
112
109
 
@@ -127,13 +124,10 @@ module KuberKit
127
124
  end
128
125
 
129
126
  module ArtifactsSync
127
+ autoload :AbstractArtifactResolver, 'artifacts_sync/abstract_artifact_resolver'
130
128
  autoload :ArtifactUpdater, 'artifacts_sync/artifact_updater'
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
129
+ autoload :GitArtifactResolver, 'artifacts_sync/git_artifact_resolver'
130
+ autoload :NullArtifactResolver, 'artifacts_sync/null_artifact_resolver'
137
131
  end
138
132
 
139
133
  module EnvFileReader
@@ -152,7 +146,6 @@ module KuberKit
152
146
  module TemplateReader
153
147
  autoload :ActionHandler, 'template_reader/action_handler'
154
148
  autoload :Reader, 'template_reader/reader'
155
- autoload :Renderer, 'template_reader/renderer'
156
149
 
157
150
  module Strategies
158
151
  autoload :Abstract, 'template_reader/strategies/abstract'
@@ -173,18 +166,6 @@ module KuberKit
173
166
  autoload :Docker, 'service_deployer/strategies/docker'
174
167
  autoload :DockerCompose, 'service_deployer/strategies/docker_compose'
175
168
  autoload :Kubernetes, 'service_deployer/strategies/kubernetes'
176
- autoload :Helm, 'service_deployer/strategies/helm'
177
- end
178
- end
179
-
180
- module ServiceGenerator
181
- autoload :ActionHandler, 'service_generator/action_handler'
182
- autoload :StrategyDetector, 'service_generator/strategy_detector'
183
- autoload :Generator, 'service_generator/generator'
184
-
185
- module Strategies
186
- autoload :Abstract, 'service_generator/strategies/abstract'
187
- autoload :Helm, 'service_generator/strategies/helm'
188
169
  end
189
170
  end
190
171
 
@@ -211,7 +192,6 @@ module KuberKit
211
192
  autoload :ServiceReader, 'actions/service_reader'
212
193
  autoload :ServiceDeployer, 'actions/service_deployer'
213
194
  autoload :ServiceChecker, 'actions/service_checker'
214
- autoload :ServiceGenerator, 'actions/service_generator'
215
195
  autoload :ConfigurationLoader, 'actions/configuration_loader'
216
196
  autoload :KubectlApplier, 'actions/kubectl_applier'
217
197
  autoload :KubectlAttacher, 'actions/kubectl_attacher'
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.1.8
4
+ version: 1.2.0
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-10-24 00:00:00.000000000 Z
11
+ date: 2022-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.16.0
19
+ version: 0.17.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.16.0
26
+ version: 0.17.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dry-auto_inject
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: cli-ui
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 2.1.0
103
+ version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 2.1.0
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: net-ssh
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -259,14 +259,13 @@ files:
259
259
  - lib/kuber_kit/actions/kubectl_logs.rb
260
260
  - lib/kuber_kit/actions/service_checker.rb
261
261
  - lib/kuber_kit/actions/service_deployer.rb
262
- - lib/kuber_kit/actions/service_generator.rb
263
262
  - lib/kuber_kit/actions/service_reader.rb
264
263
  - lib/kuber_kit/actions/shell_launcher.rb
265
264
  - lib/kuber_kit/actions/template_reader.rb
265
+ - lib/kuber_kit/artifacts_sync/abstract_artifact_resolver.rb
266
266
  - lib/kuber_kit/artifacts_sync/artifact_updater.rb
267
- - lib/kuber_kit/artifacts_sync/strategies/abstract.rb
268
- - lib/kuber_kit/artifacts_sync/strategies/git_updater.rb
269
- - lib/kuber_kit/artifacts_sync/strategies/null_updater.rb
267
+ - lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb
268
+ - lib/kuber_kit/artifacts_sync/null_artifact_resolver.rb
270
269
  - lib/kuber_kit/cli.rb
271
270
  - lib/kuber_kit/configs.rb
272
271
  - lib/kuber_kit/container.rb
@@ -284,12 +283,10 @@ files:
284
283
  - lib/kuber_kit/core/configuration_definition_factory.rb
285
284
  - lib/kuber_kit/core/configuration_factory.rb
286
285
  - lib/kuber_kit/core/configuration_store.rb
287
- - lib/kuber_kit/core/context_helper/abstract_helper.rb
288
286
  - lib/kuber_kit/core/context_helper/base_helper.rb
289
287
  - lib/kuber_kit/core/context_helper/context_helper_factory.rb
290
288
  - lib/kuber_kit/core/context_helper/context_vars.rb
291
289
  - lib/kuber_kit/core/context_helper/image_helper.rb
292
- - lib/kuber_kit/core/context_helper/local_context_helper.rb
293
290
  - lib/kuber_kit/core/context_helper/service_helper.rb
294
291
  - lib/kuber_kit/core/dependencies/abstract_dependency_resolver.rb
295
292
  - lib/kuber_kit/core/env_files/abstract_env_file.rb
@@ -346,14 +343,8 @@ files:
346
343
  - lib/kuber_kit/service_deployer/strategies/abstract.rb
347
344
  - lib/kuber_kit/service_deployer/strategies/docker.rb
348
345
  - lib/kuber_kit/service_deployer/strategies/docker_compose.rb
349
- - lib/kuber_kit/service_deployer/strategies/helm.rb
350
346
  - lib/kuber_kit/service_deployer/strategies/kubernetes.rb
351
347
  - lib/kuber_kit/service_deployer/strategy_detector.rb
352
- - lib/kuber_kit/service_generator/action_handler.rb
353
- - lib/kuber_kit/service_generator/generator.rb
354
- - lib/kuber_kit/service_generator/strategies/abstract.rb
355
- - lib/kuber_kit/service_generator/strategies/helm.rb
356
- - lib/kuber_kit/service_generator/strategy_detector.rb
357
348
  - lib/kuber_kit/service_reader/action_handler.rb
358
349
  - lib/kuber_kit/service_reader/reader.rb
359
350
  - lib/kuber_kit/shell/abstract_shell.rb
@@ -362,7 +353,6 @@ files:
362
353
  - lib/kuber_kit/shell/commands/docker_commands.rb
363
354
  - lib/kuber_kit/shell/commands/docker_compose_commands.rb
364
355
  - lib/kuber_kit/shell/commands/git_commands.rb
365
- - lib/kuber_kit/shell/commands/helm_commands.rb
366
356
  - lib/kuber_kit/shell/commands/kubectl_commands.rb
367
357
  - lib/kuber_kit/shell/commands/rsync_commands.rb
368
358
  - lib/kuber_kit/shell/commands/system_commands.rb
@@ -375,7 +365,6 @@ files:
375
365
  - lib/kuber_kit/shell_launcher/strategies/kubernetes.rb
376
366
  - lib/kuber_kit/template_reader/action_handler.rb
377
367
  - lib/kuber_kit/template_reader/reader.rb
378
- - lib/kuber_kit/template_reader/renderer.rb
379
368
  - lib/kuber_kit/template_reader/strategies/abstract.rb
380
369
  - lib/kuber_kit/template_reader/strategies/artifact_file.rb
381
370
  - lib/kuber_kit/tools/build_dir_cleaner.rb
@@ -401,14 +390,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
401
390
  requirements:
402
391
  - - ">="
403
392
  - !ruby/object:Gem::Version
404
- version: 2.7.0
393
+ version: 3.0.0
405
394
  required_rubygems_version: !ruby/object:Gem::Requirement
406
395
  requirements:
407
396
  - - ">="
408
397
  - !ruby/object:Gem::Version
409
398
  version: '0'
410
399
  requirements: []
411
- rubygems_version: 3.1.6
400
+ rubygems_version: 3.3.7
412
401
  signing_key:
413
402
  specification_version: 4
414
403
  summary: Docker Containers Build & Deployment
@@ -1,20 +0,0 @@
1
- class KuberKit::Actions::ServiceGenerator
2
- include KuberKit::Import[
3
- "shell.local_shell",
4
- "service_generator.action_handler",
5
- "ui",
6
- ]
7
-
8
- Contract Symbol, String => Any
9
- def call(service_name, path)
10
- expanded_path = File.expand_path(path)
11
- puts expanded_path
12
- action_handler.call(local_shell, service_name, expanded_path)
13
-
14
- true
15
- rescue KuberKit::Error => e
16
- ui.print_error("Error", e.message)
17
-
18
- false
19
- end
20
- end
@@ -1,9 +0,0 @@
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
@@ -1,46 +0,0 @@
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
@@ -1,12 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- class KuberKit::Core::ContextHelper::AbstractHelper
2
- def get_binding
3
- binding
4
- end
5
- end
@@ -1,14 +0,0 @@
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,41 +0,0 @@
1
- class KuberKit::ServiceDeployer::Strategies::Helm < KuberKit::ServiceDeployer::Strategies::Abstract
2
- include KuberKit::Import[
3
- "service_reader.reader",
4
- "shell.helm_commands",
5
- "shell.bash_commands",
6
- "configs",
7
- ]
8
-
9
- Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
10
- def deploy(shell, service)
11
- service_config = reader.read(shell, service)
12
- chart_root_path = File.join(configs.service_config_dir, "#{service.name}_chart")
13
- chart_templates_path = File.join(chart_root_path, "templates")
14
- chart_config_path = File.join(chart_root_path, "Chart.yaml")
15
- release_path = File.join(chart_templates_path, "release.yaml")
16
-
17
- bash_commands.mkdir_p(shell, chart_root_path)
18
- bash_commands.mkdir_p(shell, chart_templates_path)
19
-
20
- shell.write(release_path, service_config)
21
- shell.write(chart_config_path, chart_config_content(service.uri))
22
-
23
- kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
24
- namespace = KuberKit.current_configuration.deployer_namespace
25
-
26
- upgrade_result = helm_commands.upgrade(shell, service.uri, chart_root_path, kubeconfig_path: kubeconfig_path, namespace: namespace)
27
-
28
- upgrade_result
29
- end
30
-
31
- def chart_config_content(release_name)
32
- query = <<-CHART
33
- apiVersion: v2
34
- name: #{release_name}
35
- description: #{release_name}
36
- type: application
37
- version: 1.0.0
38
- appVersion: "1.0.0"
39
- CHART
40
- end
41
- end
@@ -1,16 +0,0 @@
1
- class KuberKit::ServiceGenerator::ActionHandler
2
- include KuberKit::Import[
3
- "service_generator.generator",
4
- "service_generator.strategy_detector",
5
- "core.service_store",
6
- ]
7
-
8
- Contract KuberKit::Shell::AbstractShell, Symbol, String => Any
9
- def call(shell, service_name, export_path)
10
- service = service_store.get_service(service_name)
11
-
12
- strategy_name = strategy_detector.call(service)
13
-
14
- generator.generate(shell, service, export_path, strategy_name)
15
- end
16
- end
@@ -1,26 +0,0 @@
1
- class KuberKit::ServiceGenerator::Generator
2
- StrategyNotFoundError = Class.new(KuberKit::NotFoundError)
3
-
4
- include KuberKit::Import[
5
- "core.service_store",
6
- ]
7
-
8
- def register_strategy(strategy_name, strategy)
9
- @@strategies ||= {}
10
-
11
- if !strategy.is_a?(KuberKit::ServiceGenerator::Strategies::Abstract)
12
- raise ArgumentError.new("should be an instance of KuberKit::ServiceGenerator::Strategies::Abstract, got: #{strategy.inspect}")
13
- end
14
-
15
- @@strategies[strategy_name] = strategy
16
- end
17
-
18
- Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service, String, Symbol => Any
19
- def generate(shell, service, export_path, strategy_name)
20
- generator = @@strategies[strategy_name]
21
-
22
- raise StrategyNotFoundError, "Can't find strategy with name #{strategy_name}" if generator.nil?
23
-
24
- generator.generate(shell, service, export_path)
25
- end
26
- end