kubernetes-cli 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/kubernetes-cli.rb +17 -14
- data/lib/kubernetes-cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af9eac1d2519da95a480b3c09ab883bc220e74f16695a477e4bd07cd89237027
|
4
|
+
data.tar.gz: b772583a411af61c2b7e1276faca027f6ca276c525473edf5f7b5bd879f98dde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45fef23e66bd4094b8621cc2779255ac48eb4883f7ab3141f838f46717159363dd7cf756b62a475611af91fe2ef08c0a5211c8adc580ae33eb5f9c03250a0312
|
7
|
+
data.tar.gz: e0667d9c0184a928d004b10383d0a8b5a99ae24f22088e89a7869c94b1209b241906069a763ec8e508f98bf9c383dd4f50e4927607f4cc34869acd9e3c0a61e4
|
data/CHANGELOG.md
CHANGED
data/lib/kubernetes-cli.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
require 'kubectl-rb'
|
2
2
|
|
3
3
|
class KubernetesCLI
|
4
|
+
class KubernetesError < StandardError; end
|
5
|
+
|
6
|
+
class InvalidResourceError < KubernetesError
|
7
|
+
attr_accessor :resource
|
8
|
+
end
|
9
|
+
|
10
|
+
class InvalidResourceUriError < KubernetesError
|
11
|
+
attr_accessor :resource_uri
|
12
|
+
end
|
13
|
+
|
14
|
+
class GetResourceError < KubernetesError; end
|
15
|
+
|
16
|
+
STATUS_KEY = :kubernetes_cli_last_status
|
17
|
+
|
4
18
|
attr_reader :kubeconfig_path, :executable
|
5
19
|
|
6
20
|
def initialize(kubeconfig_path, executable = KubectlRb.executable)
|
@@ -19,7 +33,7 @@ class KubernetesCLI
|
|
19
33
|
end
|
20
34
|
|
21
35
|
def last_status
|
22
|
-
Thread.current[
|
36
|
+
Thread.current[STATUS_KEY]
|
23
37
|
end
|
24
38
|
|
25
39
|
def run_cmd(cmd)
|
@@ -127,7 +141,7 @@ class KubernetesCLI
|
|
127
141
|
systemm(cmd)
|
128
142
|
|
129
143
|
unless last_status.success?
|
130
|
-
raise
|
144
|
+
raise KubernetesError, "could not annotate resource '#{name}': kubectl "\
|
131
145
|
"exited with status code #{last_status.exitstatus}"
|
132
146
|
end
|
133
147
|
end
|
@@ -151,21 +165,10 @@ class KubernetesCLI
|
|
151
165
|
@env ||= {}
|
152
166
|
end
|
153
167
|
|
154
|
-
def status_key
|
155
|
-
:kubernetes_cli_last_status
|
156
|
-
end
|
157
|
-
|
158
168
|
def base_cmd
|
159
169
|
[executable, '--kubeconfig', kubeconfig_path]
|
160
170
|
end
|
161
171
|
|
162
|
-
def backticks(cmd)
|
163
|
-
cmd_s = cmd.join(' ')
|
164
|
-
`#{cmd_s}`.tap do
|
165
|
-
self.last_status = $?
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
172
|
def execc(cmd)
|
170
173
|
run_before_callbacks(cmd)
|
171
174
|
cmd_s = cmd.join(' ')
|
@@ -212,6 +215,6 @@ class KubernetesCLI
|
|
212
215
|
end
|
213
216
|
|
214
217
|
def last_status=(status)
|
215
|
-
Thread.current[
|
218
|
+
Thread.current[STATUS_KEY] = status
|
216
219
|
end
|
217
220
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubernetes-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kubectl-rb
|