kubernetes-cli 0.4.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b93bf8e3f620c17f2781d2eb5f2748f970982a854d0aa622d3313b1d74104d3b
4
- data.tar.gz: 9c7d170e2ab873b66cfbf6a12532260e3442781330c9e96363e472d354ff997a
3
+ metadata.gz: 96aca0bc50d59662a5fe419b801b0fa54d80f9c72f70b7fc62661c2a1b740d56
4
+ data.tar.gz: 3d15ea0644c4ab7dcf8842b935c989349b92f17779fb35e00427924970ac7402
5
5
  SHA512:
6
- metadata.gz: 0156747413340bab08b571bf13db212d0a8397ceb0b733fbc152c7835080f203400f6f1554829c74dab4fe1b743b3f3eda3d2e11950896f01da6b9bedf5bc3ca
7
- data.tar.gz: c21786be60e403d60d2c39fd7be371a7043539412000e9cff2ea197e37092fe38a2bc621a6413266aabd0b8633656375056ce46745ac65726eb08c3e31cd14e3
6
+ metadata.gz: aaa458e703356f3605a3280bc960961b04b2ff4662997251444169fd55b674cda81d9f8bea83cdcb83b14cde98f9f1f38676a8764c09353e46217ff52aad0642
7
+ data.tar.gz: b1c72e557eebafa2c9d63b376ae22da6df2cff8e9fc340c0e2c7c6de014a8e2f31fa2bf6d0724b40379b6fe93fc92672ab46aa59f9732283ac11202c35e2ab6f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.6.0
2
+ * Rescue and re-raise `JSON::ParserError`s.
3
+
4
+ ## 0.5.0
5
+ * Pass environment variables to every command.
6
+
1
7
  ## 0.4.0
2
8
  * Add `#version` method to get k8s client/server version info.
3
9
  * Add Sorbet type definitions.
data/Gemfile CHANGED
@@ -16,8 +16,11 @@ group :development do
16
16
  gem 'curdle', '~> 1.0'
17
17
 
18
18
  # lock to same version as kuby-core
19
- gem 'sorbet', '= 0.5.6433'
20
- gem 'parlour', '~> 6.0'
19
+ gem 'sorbet', '= 0.5.11865'
20
+ gem 'parlour', '~> 9.0'
21
+ gem 'tapioca', '~> 0.16'
22
+ gem 'racc'
23
+ gem 'base64'
21
24
  end
22
25
 
23
26
  group :development, :test do
@@ -1,5 +1,5 @@
1
1
  # typed: ignore
2
2
 
3
3
  class KubernetesCLI
4
- VERSION = '0.4.0'.freeze
4
+ VERSION = '0.6.0'.freeze
5
5
  end
@@ -110,7 +110,11 @@ class KubernetesCLI
110
110
  "kubectl exited with status code #{last_status.exitstatus}"
111
111
  end
112
112
 
113
- JSON.parse(result)
113
+ begin
114
+ JSON.parse(result)
115
+ rescue JSON::ParserError
116
+ raise GetVersionError, "json parsing error"
117
+ end
114
118
  end
115
119
 
116
120
  # T::Sig::WithoutRuntime.sig { params(cmd: T.any(String, T::Array[String])).void }
@@ -214,7 +218,11 @@ class KubernetesCLI
214
218
  "in namespace #{namespace}: kubectl exited with status code #{last_status.exitstatus}"
215
219
  end
216
220
 
217
- JSON.parse(result)
221
+ begin
222
+ JSON.parse(result)
223
+ rescue JSON::ParserError
224
+ raise GetResourceError, "json parsing error"
225
+ end
218
226
  end
219
227
 
220
228
  # T::Sig::WithoutRuntime.sig {
@@ -248,7 +256,11 @@ class KubernetesCLI
248
256
  "in namespace #{namespace}: kubectl exited with status code #{last_status.exitstatus}"
249
257
  end
250
258
 
251
- JSON.parse(result)['items']
259
+ begin
260
+ JSON.parse(result)['items']
261
+ rescue JSON::ParserError
262
+ raise GetResourceError, "json parsing error"
263
+ end
252
264
  end
253
265
 
254
266
  # T::Sig::WithoutRuntime.sig {
@@ -440,13 +452,13 @@ class KubernetesCLI
440
452
  Thread.current[STDERR_KEY] = new_stderr
441
453
  end
442
454
 
443
- private
444
-
445
455
  # T::Sig::WithoutRuntime.sig { returns(T::Hash[String, String]) }
446
456
  def env
447
457
  @env ||= {}
448
458
  end
449
459
 
460
+ private
461
+
450
462
  # T::Sig::WithoutRuntime.sig { returns(T::Array[String]) }
451
463
  def base_cmd
452
464
  [executable, '--kubeconfig', kubeconfig_path]
@@ -456,7 +468,7 @@ class KubernetesCLI
456
468
  def execc(cmd)
457
469
  run_before_callbacks(cmd)
458
470
  cmd_s = cmd.join(' ')
459
- exec(cmd_s)
471
+ exec(env, cmd_s)
460
472
  end
461
473
 
462
474
  # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).void }
@@ -472,7 +484,7 @@ class KubernetesCLI
472
484
  def systemm_default(cmd)
473
485
  run_before_callbacks(cmd)
474
486
  cmd_s = cmd.join(' ')
475
- system(cmd_s).tap do
487
+ system(env, cmd_s).tap do
476
488
  self.last_status = $?
477
489
  run_after_callbacks(cmd)
478
490
  end
@@ -483,7 +495,7 @@ class KubernetesCLI
483
495
  run_before_callbacks(cmd)
484
496
  cmd_s = cmd.join(' ')
485
497
 
486
- Open3.popen3(cmd_s) do |p_stdin, p_stdout, p_stderr, wait_thread|
498
+ Open3.popen3(env, cmd_s) do |p_stdin, p_stdout, p_stderr, wait_thread|
487
499
  Thread.new(stdout) do |t_stdout|
488
500
  begin
489
501
  p_stdout.each { |line| t_stdout.puts(line) }
@@ -507,21 +519,7 @@ class KubernetesCLI
507
519
 
508
520
  # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).returns(String) }
509
521
  def backticks(cmd)
510
- if stdout == STDOUT && stderr == STDERR
511
- backticks_default(cmd)
512
- else
513
- backticks_open3(cmd)
514
- end
515
- end
516
-
517
- # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).returns(String) }
518
- def backticks_default(cmd)
519
- run_before_callbacks(cmd)
520
- cmd_s = cmd.join(' ')
521
- `#{cmd_s}`.tap do
522
- self.last_status = $?
523
- run_after_callbacks(cmd)
524
- end
522
+ backticks_open3(cmd)
525
523
  end
526
524
 
527
525
  # T::Sig::WithoutRuntime.sig { params(cmd: T::Array[String]).returns(String) }
@@ -530,7 +528,7 @@ class KubernetesCLI
530
528
  cmd_s = cmd.join(' ')
531
529
  result = StringIO.new
532
530
 
533
- Open3.popen3(cmd_s) do |p_stdin, p_stdout, p_stderr, wait_thread|
531
+ Open3.popen3(env, cmd_s) do |p_stdin, p_stdout, p_stderr, wait_thread|
534
532
  Thread.new do
535
533
  begin
536
534
  p_stdout.each { |line| result.puts(line) }
@@ -192,9 +192,6 @@ class KubernetesCLI
192
192
  sig { params(cmd: T::Array[String]).returns(String) }
193
193
  def backticks(cmd); end
194
194
 
195
- sig { params(cmd: T::Array[String]).returns(String) }
196
- def backticks_default(cmd); end
197
-
198
195
  sig { params(cmd: T::Array[String]).returns(String) }
199
196
  def backticks_open3(cmd); end
200
197
 
@@ -2,7 +2,8 @@
2
2
  require 'rspec/expectations'
3
3
 
4
4
  class TestCommand
5
- def initialize(cmd_s)
5
+ def initialize(env, cmd_s)
6
+ @env = env
6
7
  @cmd_s = cmd_s
7
8
  @cmd = cmd_s.split(' ')
8
9
  end
@@ -32,7 +33,7 @@ module CommandHelpers
32
33
  @extra = []
33
34
  @missing_redirect = false
34
35
 
35
- commands.map! { |cmd_s| TestCommand.new(cmd_s) }
36
+ commands.map! { |env, cmd_s| TestCommand.new(env, cmd_s) }
36
37
 
37
38
  @matching_commands = commands.select do |cmd|
38
39
  missing_for_cmd = []
@@ -17,21 +17,15 @@ class FakeStatus
17
17
  end
18
18
 
19
19
  class TestCLI < KubernetesCLI
20
- attr_reader :exec_commands, :system_commands
20
+ attr_reader :exec_commands
21
21
 
22
22
  def initialize(kubeconfig_path, executable = KubectlRb.executable)
23
23
  @exec_commands = []
24
- @system_commands = []
25
24
 
26
25
  super
27
26
  end
28
27
 
29
- def on_exec(&block)
30
- @exec_callback = block
31
- end
32
-
33
- def exec(cmd)
34
- @exec_commands << cmd
35
- @exec_callback.call(cmd) if @exec_callback
28
+ def exec(env, cmd)
29
+ @exec_commands << [env, cmd]
36
30
  end
37
31
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubernetes-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-05-05 00:00:00.000000000 Z
10
+ date: 2025-02-28 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: kubectl-rb
@@ -51,7 +50,6 @@ homepage: http://github.com/getkuby/kubernetes-cli
51
50
  licenses:
52
51
  - MIT
53
52
  metadata: {}
54
- post_install_message:
55
53
  rdoc_options: []
56
54
  require_paths:
57
55
  - lib
@@ -66,8 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
64
  - !ruby/object:Gem::Version
67
65
  version: '0'
68
66
  requirements: []
69
- rubygems_version: 3.2.32
70
- signing_key:
67
+ rubygems_version: 3.6.2
71
68
  specification_version: 4
72
69
  summary: Ruby wrapper around the Kubernetes CLI.
73
70
  test_files: []