stax-helm 0.0.5 → 0.0.6

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: 3e178ccf3c2eb22366c6fd4adc71807ab0a60384670d72b820d0856926e13fd8
4
- data.tar.gz: 4c3e91044ced3fa7d49ebcea2f3a1523680b43102c712837e9eec8f37304d718
3
+ metadata.gz: 7beb0767d7b08899165a52b8e58886c667a3d4d74a1a9e0e5918d599d0e755f8
4
+ data.tar.gz: 913a768e730ccdb511c1e2477d25d0b4438e1f14cdd81bd79099fd1766ccf1ba
5
5
  SHA512:
6
- metadata.gz: 40703184413567c349b575ff6e3498ed05f53bd3a234f54c8ce2fa05edf501d6cdd7d4046d0fe44064ce7dfb0d05baa454579269033191df3eb8302b6dbb7b1d
7
- data.tar.gz: 6ef7cc00627ff83328feabe4ecf84d487bfa0b1bf0677753a6147bbf0194df47173a851ab48a2f55cfa0e461b1af20b29fd576b34618ddc9db61f24921017de8
6
+ metadata.gz: 7b8aee9ce577d1ec38b3a33ce446ff00f44bde274bae2aa0b8cf5934eebae30f7831683c0ac8b79e6330951cacc98e3aa8b78e1f50fff31bffab5fbb90ca0283
7
+ data.tar.gz: 566b8097eb9e92660459b4cc252b7aa3c922df810417435a578c6a7d183111c6a70bc00322e6ee1e20a324ab7ada73b076cc7b11649343a0ac21c421ccde4dfc
@@ -3,11 +3,39 @@ module Stax
3
3
  module Helm
4
4
  class Cmd < Base
5
5
 
6
+ no_commands do
7
+ def helm_deployments
8
+ jsonpath = '{.items[*].metadata.name}'
9
+ %x[kubectl get deployments -o=jsonpath='#{jsonpath}' -l #{helm_selector}].split
10
+ end
11
+
12
+ ## prompt user with a list of deployments to choose
13
+ def helm_ask_deployments(msg)
14
+ deployments = helm_deployments
15
+ if deployments.count > 1
16
+ puts deployments.each_with_index.map { |d, i| "#{i}: #{d}" }
17
+ resp = ask(msg, default: 'all')
18
+ if resp != 'all'
19
+ indices = resp.split.map(&:to_i)
20
+ deployments = Array(deployments.slice(*indices))
21
+ end
22
+ end
23
+ deployments
24
+ end
25
+ end
26
+
6
27
  desc 'deployments', 'list deployments'
7
28
  def deployments
8
29
  kubectl_run(:get, :deployments, '-l', helm_selector)
9
30
  end
10
31
 
32
+ desc 'restart', 'restart deployments'
33
+ def restart
34
+ helm_ask_deployments('choose deployments').each do |deployment|
35
+ kubectl_run(:rollout, :restart, :deployment, deployment)
36
+ end
37
+ end
38
+
11
39
  end
12
40
  end
13
41
  end
@@ -33,6 +33,7 @@ module Stax
33
33
 
34
34
  desc 'logs [OPTIONS]', 'run kubectl logs with same options'
35
35
  def logs(*args)
36
+ trap('SIGINT', 'EXIT') # clean exit with ctrl-c
36
37
  args = [ '--all-containers', '--prefix', '--follow' ] if args.empty? # helpful default args
37
38
  kubectl_run(:logs, '-l', helm_selector, *args)
38
39
  end
@@ -16,6 +16,7 @@ module Stax
16
16
  ## pass through args to stern
17
17
  desc 'stern [STERN_ARGS]', 'use stern to show logs'
18
18
  def stern(*args)
19
+ trap('SIGINT', 'EXIT') # clean exit with ctrl-c
19
20
  stern_run('-l', helm_selector, *args)
20
21
  end
21
22
 
@@ -1,5 +1,5 @@
1
1
  module Stax
2
2
  module Helm
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stax-helm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-27 00:00:00.000000000 Z
11
+ date: 2020-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler