Skip to content

Commit 997df34

Browse files
committed
Re-raise JSON parsing errors
1 parent cb849ae commit 997df34

File tree

4 files changed

+65
-43
lines changed

4 files changed

+65
-43
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby 3.0.3
1+
ruby 3.4.2

Gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ group :development do
1616
gem 'curdle', '~> 1.0'
1717

1818
# lock to same version as kuby-core
19-
gem 'sorbet', '= 0.5.10851'
20-
gem 'parlour', '~> 7.0'
21-
gem 'tapioca', '~> 0.11'
19+
gem 'sorbet', '= 0.5.11865'
20+
gem 'parlour', '~> 9.0'
21+
gem 'tapioca', '~> 0.16'
22+
gem 'racc'
23+
gem 'base64'
2224
end
2325

2426
group :development, :test do

Gemfile.lock

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,49 @@ GEM
88
remote: https://rubygems.org/
99
specs:
1010
ast (2.4.2)
11+
base64 (0.2.0)
12+
benchmark (0.4.0)
1113
byebug (11.1.3)
1214
coderay (1.1.3)
13-
commander (4.6.0)
14-
highline (~> 2.0.0)
15+
commander (5.0.0)
16+
highline (~> 3.0.0)
1517
curdle (1.2.2)
1618
parser (~> 3.1)
1719
diff-lcs (1.5.0)
1820
dry-inflector (0.3.0)
19-
highline (2.0.3)
21+
erubi (1.13.1)
22+
highline (3.0.1)
23+
kind-rb (0.1.0-arm64-darwin)
2024
kind-rb (0.1.0-x86_64-darwin)
2125
kind-rb (0.1.0-x86_64-linux)
2226
kube-dsl (0.7.5)
2327
dry-inflector (~> 0.2)
28+
kubectl-rb (0.2.1-arm64-darwin)
2429
kubectl-rb (0.2.1-x86_64-darwin)
2530
kubectl-rb (0.2.1-x86_64-linux)
2631
method_source (1.0.0)
2732
netrc (0.11.0)
28-
parallel (1.23.0)
29-
parlour (7.0.0)
30-
commander (~> 4.5)
33+
parallel (1.26.3)
34+
parlour (9.0.0)
35+
commander (~> 5.0)
3136
parser
3237
rainbow (~> 3.0)
3338
sorbet-runtime (>= 0.5)
3439
parser (3.2.2.1)
3540
ast (~> 2.4.1)
41+
prism (1.3.0)
3642
pry (0.14.2)
3743
coderay (~> 1.1)
3844
method_source (~> 1.0)
3945
pry-byebug (3.10.1)
4046
byebug (~> 11.0)
4147
pry (>= 0.13, < 0.15)
48+
racc (1.8.1)
4249
rainbow (3.1.1)
4350
rake (13.0.6)
44-
rbi (0.0.16)
45-
ast
46-
parser (>= 2.6.4.0)
51+
rbi (0.2.4)
52+
prism (~> 1.0)
4753
sorbet-runtime (>= 0.5.9204)
48-
unparser
4954
rspec (3.12.0)
5055
rspec-core (~> 3.12.0)
5156
rspec-expectations (~> 3.12.0)
@@ -59,52 +64,55 @@ GEM
5964
diff-lcs (>= 1.2.0, < 2.0)
6065
rspec-support (~> 3.12.0)
6166
rspec-support (3.12.0)
62-
sorbet (0.5.10851)
63-
sorbet-static (= 0.5.10851)
64-
sorbet-runtime (0.5.10851)
65-
sorbet-static (0.5.10851-universal-darwin-20)
66-
sorbet-static (0.5.10851-x86_64-linux)
67-
sorbet-static-and-runtime (0.5.10851)
68-
sorbet (= 0.5.10851)
69-
sorbet-runtime (= 0.5.10851)
70-
spoom (1.2.1)
71-
sorbet (>= 0.5.10187)
72-
sorbet-runtime (>= 0.5.9204)
67+
sorbet (0.5.11865)
68+
sorbet-static (= 0.5.11865)
69+
sorbet-runtime (0.5.11865)
70+
sorbet-static (0.5.11865-universal-darwin)
71+
sorbet-static (0.5.11865-x86_64-linux)
72+
sorbet-static-and-runtime (0.5.11865)
73+
sorbet (= 0.5.11865)
74+
sorbet-runtime (= 0.5.11865)
75+
spoom (1.5.4)
76+
erubi (>= 1.10.0)
77+
prism (>= 0.28.0)
78+
rbi (>= 0.2.3)
79+
sorbet-static-and-runtime (>= 0.5.10187)
7380
thor (>= 0.19.2)
74-
tapioca (0.11.6)
81+
tapioca (0.16.11)
82+
benchmark
7583
bundler (>= 2.2.25)
7684
netrc (>= 0.11.0)
7785
parallel (>= 1.21.0)
78-
rbi (~> 0.0.0, >= 0.0.16)
79-
sorbet-static-and-runtime (>= 0.5.10187)
80-
spoom (~> 1.2.0, >= 1.2.0)
86+
rbi (~> 0.2)
87+
sorbet-static-and-runtime (>= 0.5.11087)
88+
spoom (>= 1.2.0)
8189
thor (>= 1.2.0)
8290
yard-sorbet
83-
thor (1.2.2)
84-
unparser (0.6.7)
85-
diff-lcs (~> 1.3)
86-
parser (>= 3.2.0)
87-
yard (0.9.34)
88-
yard-sorbet (0.8.1)
89-
sorbet-runtime (>= 0.5)
90-
yard (>= 0.9)
91+
thor (1.3.2)
92+
yard (0.9.37)
93+
yard-sorbet (0.9.0)
94+
sorbet-runtime
95+
yard
9196

9297
PLATFORMS
98+
arm64-darwin-23
9399
x86_64-darwin-20
94100
x86_64-linux
95101

96102
DEPENDENCIES
103+
base64
97104
curdle (~> 1.0)
98105
kind-rb (~> 0.1)
99106
kube-dsl (~> 0.6)
100107
kubectl-rb
101108
kubernetes-cli!
102-
parlour (~> 7.0)
109+
parlour (~> 9.0)
103110
pry-byebug
111+
racc
104112
rake
105113
rspec
106-
sorbet (= 0.5.10851)
107-
tapioca (~> 0.11)
114+
sorbet (= 0.5.11865)
115+
tapioca (~> 0.16)
108116

109117
BUNDLED WITH
110118
2.4.5

lib/kubernetes-cli.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ def version
110110
"kubectl exited with status code #{last_status.exitstatus}"
111111
end
112112

113-
JSON.parse(result)
113+
begin
114+
JSON.parse(result)
115+
rescue JSON::ParserError
116+
raise GetVersionError, "json parsing error"
117+
end
114118
end
115119

116120
T::Sig::WithoutRuntime.sig { params(cmd: T.any(String, T::Array[String])).void }
@@ -214,7 +218,11 @@ def get_object(type, namespace, name)
214218
"in namespace #{namespace}: kubectl exited with status code #{last_status.exitstatus}"
215219
end
216220

217-
JSON.parse(result)
221+
begin
222+
JSON.parse(result)
223+
rescue JSON::ParserError
224+
raise GetResourceError, "json parsing error"
225+
end
218226
end
219227

220228
T::Sig::WithoutRuntime.sig {
@@ -248,7 +256,11 @@ def get_objects(type, namespace, match_labels = {})
248256
"in namespace #{namespace}: kubectl exited with status code #{last_status.exitstatus}"
249257
end
250258

251-
JSON.parse(result)['items']
259+
begin
260+
JSON.parse(result)['items']
261+
rescue JSON::ParserError
262+
raise GetResourceError, "json parsing error"
263+
end
252264
end
253265

254266
T::Sig::WithoutRuntime.sig {

0 commit comments

Comments
 (0)