kuber_kit 1.1.1 → 1.1.2

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: f7172b9ae75ac4a18cbc1c82517b748fe4a089916f6bf56960548357b6b978a6
4
- data.tar.gz: 2a21fb1b7d9d2b660a78633161354badd391c39d6c95a252254f3b8af694bc69
3
+ metadata.gz: e8c0e83354ec30de497af66249d04c6215dd969e72cb53e81ebcf3865f3c4aee
4
+ data.tar.gz: a3e2cc808700f3ffb3409cf06966fe1a145762cf0b6d992846b9f8a91cc9b2a4
5
5
  SHA512:
6
- metadata.gz: 24e689ebd9a561abc36b4ecb6d30de8662c29691143f50d05832e95dff27350b70029e98c6c137f3bd94b1d12f7feb42eda0da0f63dc5fdc3ef021a820bcb26f
7
- data.tar.gz: 01aa2bc0d0ab6d0791146d3d08f236f246ac03a1b9ea04cca04472aea25adb769edc8c7f8c185df74d57bb355c176458e69ddc0b5af631e3bd01975be10694f1
6
+ metadata.gz: 937fcf8e351cd6177c5768e6be21dc8c25a4aa4e677a182ae448f4c5838cd5d67cce664b79aefce434ca305796368e3e5c2d103eb84de15ad0340402e8ffbbfe
7
+ data.tar.gz: 6fd5a04bb20c18e052256e7747b32d3eb78b68ac69e70897f6794c93f96ecb1f3fdbb232dd9dff1650c1580e298ee3529dd016b70bff3f2e4f27ec1713882256
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.8
1
+ 2.7.6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ **1.2.1**
2
+ - Update shell commands so that STDERR stream won't be merged for commands using the command result.
3
+ - kit sh would also set current default configuration
4
+ - kit get supports "api" ui
5
+ - show sync description (git/local) for artifact sync
6
+
7
+ **1.2.0**
8
+ - Change minimal ruby version to 3
9
+
1
10
  **1.1.1**
2
11
  - Change minimal ruby version to 2.7
3
12
 
data/README.md CHANGED
@@ -19,7 +19,7 @@ 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.1 |
22
+ | 2.7 | 1.1.2 |
23
23
 
24
24
  ## Usage
25
25
 
@@ -109,9 +109,9 @@ class KuberKit::Actions::ConfigurationLoader
109
109
 
110
110
  artifact_task_group = ui.create_task_group
111
111
  not_local_artifacts.each do |artifact|
112
- artifact_task_group.add("Updating #{artifact.name.to_s.yellow}") do |task|
112
+ artifact_task_group.add("Updating #{artifact.name.to_s.yellow} [#{artifact.sync_description.cyan}]") do |task|
113
113
  artifact_updater.update(local_shell, artifact)
114
- task.update_title("Updated #{artifact.name.to_s.green}")
114
+ task.update_title("Updating #{artifact.name.to_s.green} [#{artifact.sync_description.cyan}]")
115
115
  end
116
116
  end
117
117
  artifact_task_group.wait
@@ -6,7 +6,7 @@ class KuberKit::Actions::KubectlGet
6
6
  "ui"
7
7
  ]
8
8
 
9
- Contract Maybe[String], Hash => Any
9
+ Contract Maybe[String], Hash => Array
10
10
  def call(resource_name, options)
11
11
  kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
12
12
  deployer_namespace = KuberKit.current_configuration.deployer_namespace
@@ -23,10 +23,10 @@ class KuberKit::Actions::KubectlGet
23
23
 
24
24
  ui.print_info("Pods", resources.join("\n"))
25
25
 
26
- true
26
+ resources
27
27
  rescue KuberKit::Error => e
28
28
  ui.print_error("Error", e.message)
29
29
 
30
- false
30
+ []
31
31
  end
32
32
  end
data/lib/kuber_kit/cli.rb CHANGED
@@ -177,7 +177,11 @@ class KuberKit::CLI < Thor
177
177
  setup(options)
178
178
 
179
179
  if KuberKit::Container['actions.configuration_loader'].call(options.merge(load_inventory: false))
180
- KuberKit::Container['actions.kubectl_get'].call(pod_name, options)
180
+ pods = KuberKit::Container['actions.kubectl_get'].call(pod_name, options)
181
+
182
+ print_result("Fetched list of pods", result: {
183
+ pods: pods
184
+ })
181
185
  end
182
186
  end
183
187
 
@@ -5,7 +5,7 @@ class KuberKit::Configs
5
5
  :image_dockerfile_name, :image_build_context_dir, :image_tag, :docker_ignore_list, :image_compile_dir, :remote_image_compile_dir,
6
6
  :kuber_kit_dirname, :kuber_kit_min_version, :images_dirname, :services_dirname, :infra_dirname, :configurations_dirname,
7
7
  :artifact_clone_dir, :service_config_dir, :deployer_strategy, :compile_simultaneous_limit, :deploy_simultaneous_limit,
8
- :additional_images_paths, :deprecation_warnings_disabled, :log_file_path, :env_file_compile_dir, :shell_launcher_strategy
8
+ :additional_images_paths, :deprecation_warnings_disabled, :log_file_path, :env_file_compile_dir, :shell_launcher_strategy, :shell_launcher_sets_configration
9
9
  ]
10
10
  DOCKER_IGNORE_LIST = [
11
11
  'Dockerfile',
@@ -59,6 +59,7 @@ class KuberKit::Configs
59
59
  set :deprecation_warnings_disabled, false
60
60
  set :log_file_path, File.join(absolute_kuber_kit_path, "deploy.log")
61
61
  set :env_file_compile_dir, File.join(absolute_kuber_kit_path, "env_files")
62
+ set :shell_launcher_sets_configration, true
62
63
  end
63
64
 
64
65
  def items
@@ -10,4 +10,8 @@ class KuberKit::Core::Artifacts::AbstractArtifact
10
10
  def namespace
11
11
  raise KuberKit::NotImplementedError, "must be implemented"
12
12
  end
13
+
14
+ def sync_description
15
+ raise KuberKit::NotImplementedError, "must be implemented"
16
+ end
13
17
  end
@@ -19,4 +19,8 @@ class KuberKit::Core::Artifacts::Git < KuberKit::Core::Artifacts::AbstractArtifa
19
19
  configs = KuberKit::Container['configs']
20
20
  "#{configs.artifact_clone_dir}/#{name}"
21
21
  end
22
+
23
+ def sync_description
24
+ "#{remote_url}:#{branch}"
25
+ end
22
26
  end
@@ -11,4 +11,8 @@ class KuberKit::Core::Artifacts::Local < KuberKit::Core::Artifacts::AbstractArti
11
11
  def cloned_path
12
12
  root_path
13
13
  end
14
+
15
+ def sync_description
16
+ "local"
17
+ end
14
18
  end
@@ -1,27 +1,27 @@
1
1
  require 'time'
2
2
  class KuberKit::Shell::Commands::BashCommands
3
3
  def rm(shell, path)
4
- shell.exec!(%Q{rm "#{path}"})
4
+ shell.exec!(%Q{rm "#{path}"}, merge_stderr: true)
5
5
  end
6
6
 
7
7
  def rm_rf(shell, path)
8
- shell.exec!(%Q{rm -rf "#{path}"})
8
+ shell.exec!(%Q{rm -rf "#{path}"}, merge_stderr: true)
9
9
  end
10
10
 
11
11
  def cp(shell, source_path, dest_path)
12
- shell.exec!(%Q{cp "#{source_path}" "#{dest_path}"})
12
+ shell.exec!(%Q{cp "#{source_path}" "#{dest_path}"}, merge_stderr: true)
13
13
  end
14
14
 
15
15
  def cp_r(shell, source_path, dest_path)
16
- shell.exec!(%Q{cp -r "#{source_path}" "#{dest_path}"})
16
+ shell.exec!(%Q{cp -r "#{source_path}" "#{dest_path}"}, merge_stderr: true)
17
17
  end
18
18
 
19
19
  def mkdir(shell, path)
20
- shell.exec!(%Q{mkdir "#{path}"})
20
+ shell.exec!(%Q{mkdir "#{path}"}, merge_stderr: true)
21
21
  end
22
22
 
23
23
  def mkdir_p(shell, path)
24
- shell.exec!(%Q{mkdir -p "#{path}"})
24
+ shell.exec!(%Q{mkdir -p "#{path}"}, merge_stderr: true)
25
25
  end
26
26
 
27
27
  def ctime(shell, path)
@@ -3,15 +3,15 @@ class KuberKit::Shell::Commands::DockerCommands
3
3
  default_args = ["--rm=true"]
4
4
  args_list = (default_args + args).join(" ")
5
5
 
6
- shell.exec!(%Q{docker image build #{build_dir} #{args_list}})
6
+ shell.exec!(%Q{docker image build #{build_dir} #{args_list}}, merge_stderr: true)
7
7
  end
8
8
 
9
9
  def tag(shell, image_name, tag_name)
10
- shell.exec!(%Q{docker tag #{image_name} #{tag_name}})
10
+ shell.exec!(%Q{docker tag #{image_name} #{tag_name}}, merge_stderr: true)
11
11
  end
12
12
 
13
13
  def push(shell, tag_name)
14
- shell.exec!(%Q{docker push #{tag_name}})
14
+ shell.exec!(%Q{docker push #{tag_name}}, merge_stderr: true)
15
15
  end
16
16
 
17
17
  def run(shell, image_name, args: nil, command: nil, detached: false, interactive: false)
@@ -25,7 +25,7 @@ class KuberKit::Shell::Commands::DockerCommands
25
25
  if interactive
26
26
  shell.interactive!(command_parts.join(" "))
27
27
  else
28
- shell.exec!(command_parts.join(" "))
28
+ shell.exec!(command_parts.join(" "), merge_stderr: true)
29
29
  end
30
30
  end
31
31
 
@@ -15,7 +15,7 @@ class KuberKit::Shell::Commands::DockerComposeCommands
15
15
  if interactive
16
16
  shell.interactive!(command_parts.join(" "))
17
17
  else
18
- shell.exec!(command_parts.join(" "))
18
+ shell.exec!(command_parts.join(" "), merge_stderr: true)
19
19
  end
20
20
  end
21
21
  end
@@ -1,36 +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(" && ")
6
+ ].join(" && "), merge_stderr: true)
7
7
  rescue KuberKit::Shell::AbstractShell::ShellError
8
8
  return nil
9
9
  end
10
10
 
11
11
  def get_version_hash(shell, git_repo_path)
12
- shell.exec! [
12
+ shell.exec!([
13
13
  "cd #{git_repo_path}",
14
14
  "git rev-parse --short HEAD",
15
- ].join(" && ")
15
+ ].join(" && "), merge_stderr: true)
16
16
  end
17
17
 
18
18
  def download_repo(shell, remote_url:, path:, branch:)
19
- shell.exec! [
19
+ shell.exec!([
20
20
  "rm -rf #{path}",
21
21
  "mkdir -p #{path}",
22
22
  "git clone -b #{branch} --depth 1 #{remote_url} #{path}",
23
- ].join(" && ")
23
+ ].join(" && "), merge_stderr: true)
24
24
  end
25
25
 
26
26
  def force_pull_repo(shell, path:, branch:)
27
- shell.exec! [
27
+ shell.exec!([
28
28
  "cd #{path}",
29
29
  "git add .",
30
30
  "git reset HEAD --hard",
31
31
  "git checkout #{branch}",
32
32
  "git reset --hard '@{u}'",
33
33
  "git pull --force",
34
- ].join(" && ")
34
+ ].join(" && "), merge_stderr: true)
35
35
  end
36
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 = []
@@ -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(' ')}})
25
+ shell.exec!(%Q{rsync -a #{args.join(' ')}}, merge_stderr: true)
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}")
5
+ shell.exec!("kill -9 #{pid}", merge_stderr: true)
6
6
  true
7
7
  rescue
8
8
  false
@@ -9,7 +9,9 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
9
9
  "ui",
10
10
  ]
11
11
 
12
- def exec!(command, log_command: true)
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)
13
15
  command_number = command_counter.get_number.to_s.rjust(2, "0")
14
16
 
15
17
  if log_command
@@ -17,7 +19,9 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
17
19
  end
18
20
 
19
21
  result = nil
20
- IO.popen(wrap_command_with_pid(command), err: [:child, :out]) do |io|
22
+
23
+ options = merge_stderr ? {err: [:child, :out]} : {}
24
+ IO.popen(wrap_command_with_pid(command), **options) do |io|
21
25
  result = io.read.chomp.strip
22
26
  end
23
27
 
@@ -88,21 +92,21 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
88
92
  end
89
93
 
90
94
  def delete(file_path)
91
- exec!("rm #{file_path}")
95
+ exec!("rm #{file_path}", merge_stderr: true)
92
96
  end
93
97
 
94
98
  def file_exists?(file_path)
95
- exec!("test -f #{file_path} && echo 'true' || echo 'false'", log_command: false) == 'true'
99
+ exec!("test -f #{file_path} && echo 'true' || echo 'false'", log_command: false, merge_stderr: true) == 'true'
96
100
  end
97
101
 
98
102
  def dir_exists?(dir_path)
99
- exec!("test -d #{dir_path} && echo 'true' || echo 'false'", log_command: false) == 'true'
103
+ exec!("test -d #{dir_path} && echo 'true' || echo 'false'", log_command: false, merge_stderr: true) == 'true'
100
104
  end
101
105
 
102
106
  def recursive_list_files(path, name: nil)
103
107
  command = %Q{find -L #{path} -type f}
104
108
  command += " -name '#{name}'" if name
105
- exec!(command).split(/[\r\n]+/)
109
+ exec!(command, merge_stderr: true).split(/[\r\n]+/)
106
110
  rescue => e
107
111
  if e.message.include?("No such file or directory")
108
112
  raise DirNotFoundError.new("Dir not found: #{path}")
@@ -113,7 +117,7 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
113
117
 
114
118
  def list_dirs(path)
115
119
  command = %Q{find -L #{path} -maxdepth 0 -type d}
116
- exec!(command).split(/[\r\n]+/)
120
+ exec!(command, merge_stderr: true).split(/[\r\n]+/)
117
121
  rescue => e
118
122
  if e.message.include?("No such file or directory")
119
123
  raise DirNotFoundError.new("Dir not found: #{path}")
@@ -22,7 +22,7 @@ class KuberKit::Shell::SshSession
22
22
  @session = nil
23
23
  end
24
24
 
25
- def exec!(command)
25
+ def exec!(command, merge_stderr: false)
26
26
  stdout_data = ''
27
27
  stderr_data = ''
28
28
  exit_code = nil
@@ -38,6 +38,10 @@ 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
41
45
  end
42
46
 
43
47
  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)
23
+ def exec!(command, log_command: true, merge_stderr: false)
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))
30
+ result = ssh_session.exec!(wrap_command_with_pid(command), merge_stderr: merge_stderr)
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,6 +17,15 @@ 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
+
20
29
  shell.replace!(env: ["KUBECONFIG=#{kubeconfig_path}", "KUBER_KIT_SHELL_CONFIGURATION=#{KuberKit.current_configuration.name}"])
21
30
  end
22
31
  end
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
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: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Khaziev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-17 00:00:00.000000000 Z
11
+ date: 2023-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts
@@ -382,7 +382,7 @@ homepage: https://github.com/ArtStation/kuber_kit
382
382
  licenses:
383
383
  - MIT
384
384
  metadata: {}
385
- post_install_message:
385
+ post_install_message:
386
386
  rdoc_options: []
387
387
  require_paths:
388
388
  - lib
@@ -397,8 +397,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
397
397
  - !ruby/object:Gem::Version
398
398
  version: '0'
399
399
  requirements: []
400
- rubygems_version: 3.1.4
401
- signing_key:
400
+ rubygems_version: 3.1.6
401
+ signing_key:
402
402
  specification_version: 4
403
403
  summary: Docker Containers Build & Deployment
404
404
  test_files: []