Skip to content

Commit f9f3710

Browse files
committed
Fix rubocop
Apparently for a while I had a broken github actions config so Rubocop wasn't actually running in CI... Plus some new linting from bumping rubocop's TargetRubyVersion. Also fix test_watch_pod_api_bearer_token_success leaking a temp file.
1 parent 75b1e52 commit f9f3710

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

lib/kubeclient.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def self.parse_definition(kind, name)
225225
# So don't expect full last word to match.
226226
/^(?<prefix>.*[A-Z])(?<singular_suffix>[^A-Z]*)$/ =~ kind # "NetworkP", "olicy"
227227
if name.start_with?(prefix.downcase)
228-
plural_suffix = name[prefix.length..-1] # "olicies"
228+
plural_suffix = name[prefix.length..] # "olicies"
229229
prefix_underscores = underscore_entity(prefix) # "network_p"
230230
method_names = [
231231
prefix_underscores + singular_suffix, # "network_policy"
@@ -482,7 +482,8 @@ def delete_entity(resource_name, name, namespace = nil, delete_options: {})
482482
# :orphan_dependents (bool) - should the dependent objects be orphaned
483483
# :propagation_policy (string) - one of Foreground|Background|Orphan
484484
# :resource_version (string) - sets a limit on the resource versions that can be served
485-
# :resource_version_match (string) - determines how the resource_version constraint will be applied
485+
# :resource_version_match (string) - determines how the resource_version constraint
486+
# will be applied
486487
# :timeout_seconds (integer) - limits the duraiton of the call
487488
# :continue (string) - a token used to retrieve the next chunk of entities
488489
# :as (:raw|:ros) - defaults to :ros
@@ -761,7 +762,7 @@ def http_options(uri)
761762
http_proxy_uri: @http_proxy_uri,
762763
http_max_redirects: http_max_redirects,
763764
bearer_token_file: @auth_options[:bearer_token_file],
764-
bearer_token: @auth_options[:bearer_token],
765+
bearer_token: @auth_options[:bearer_token]
765766
}
766767

767768
if uri.scheme == 'https'

lib/kubeclient/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
# Kubernetes REST-API Client
44
module Kubeclient
5-
VERSION = '4.10.1'.freeze
5+
VERSION = '4.10.1'
66
end

test/test_watch.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,18 @@ def test_watch_pod_api_bearer_token_file_success
113113
watcher = client.watch_pods(as: :raw)
114114

115115
begin
116-
file.write("valid_token")
116+
file.write('valid_token')
117117
file.rewind
118118
stub_token = stub_request(:get, %r{/watch/pods})
119-
.with(headers: { Authorization: 'Bearer valid_token' })
120-
.to_return(body: open_test_file('watch_stream.json'), status: 200)
119+
.with(headers: { Authorization: 'Bearer valid_token' })
120+
.to_return(body: open_test_file('watch_stream.json'), status: 200)
121121

122122
got = nil
123123
watcher.each { |notice| got = notice }
124124
assert_match(/\A{"type":"DELETED"/, got)
125125
remove_request_stub(stub_token)
126126

127-
file.write("rotated_token")
127+
file.write('rotated_token')
128128
file.close
129129
stub_request(:get, %r{/watch/pods})
130130
.with(headers: { Authorization: 'Bearer rotated_token' })
@@ -134,8 +134,8 @@ def test_watch_pod_api_bearer_token_file_success
134134
watcher.each { |notice| got = notice }
135135
assert_match(/\A{"type":"DELETED"/, got)
136136
ensure
137-
file.close
138-
file.unlink # deletes the temp file
137+
file.close
138+
file.unlink # deletes the temp file
139139
end
140140
end
141141

@@ -145,16 +145,19 @@ def test_watch_pod_api_bearer_token_success
145145
file = Tempfile.new('token')
146146
client = Kubeclient::Client.new(
147147
'http://localhost:8080/api/', 'v1',
148-
auth_options: { bearer_token: "valid_token" }
148+
auth_options: { bearer_token: 'valid_token' }
149149
)
150150

151-
stub_token = stub_request(:get, %r{/watch/pods})
151+
stub_request(:get, %r{/watch/pods})
152152
.with(headers: { Authorization: 'Bearer valid_token' })
153153
.to_return(body: open_test_file('watch_stream.json'), status: 200)
154154

155155
got = nil
156156
client.watch_pods(as: :raw).each { |notice| got = notice }
157157
assert_match(/\A{"type":"DELETED"/, got)
158+
ensure
159+
file.close
160+
file.unlink # deletes the temp file
158161
end
159162

160163
# Ensure that WatchStream respects a format that's not JSON

0 commit comments

Comments
 (0)