Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,32 @@ jobs:
runs-on: ${{ matrix.os_and_command.os }}
strategy:
matrix:
ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1', 'ruby-head', 'truffleruby-head' ]
ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1', 'ruby-head' ]
# The k0s script does more testing but needs docker, only works on ubuntu.
os_and_command:
- os: 'macos-latest'
- os: macos-latest
command: 'env TESTOPTS="--verbose" bundle exec rake test'
- os: windows-latest
command: 'env TESTOPTS="--verbose" bundle exec rake test'
- os: ubuntu-latest
# Sometimes minitest starts and then just hangs printing nothing.
# Github by default kills after 6hours(!). Hopefully SIGTERM may let it print some details?
command: 'timeout --signal=TERM 3m env TESTOPTS="--verbose" test/config/update_certs_k0s.rb'
include:
# run rubocop against lowest supported ruby
- os: ubuntu-latest
ruby: '2.5'
command: 'bundle exec rake rubocop'
# As of 2022 Aug, truffleruby-dev-builder had no build for windows.
- ruby: 'truffleruby-head'
os_and_command:
- os: macos-latest
command: 'env TESTOPTS="--verbose" bundle exec rake test'
- ruby: 'truffleruby-head'
os_and_command:
os: ubuntu-latest
command: 'timeout --signal=TERM 3m env TESTOPTS="--verbose" test/config/update_certs_k0s.rb'
# Run rubocop in 1 job only, against lowest supported ruby.
- ruby: '2.5'
os_and_command:
- os: ubuntu-latest
command: 'bundle exec rake rubocop'
name: ${{ matrix.os_and_command.os }} ${{ matrix.ruby }} rake ${{ matrix.os_and_command.command }}
steps:
- uses: actions/checkout@v2
Expand All @@ -35,7 +48,6 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: false # disable running 'bundle install' and caching installed gems see https://github.com/httprb/http/issues/572
- run: gem install rake bundler
- run: bundle install
- run: ${{ matrix.os_and_command.command }}
timeout-minutes: 10
Expand Down
2 changes: 2 additions & 0 deletions kubeclient.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency('mocha', '~> 1.5')
spec.add_development_dependency 'openid_connect', '~> 1.1'
spec.add_development_dependency 'net-smtp'
# needed on Windows, at least for openid_connect
spec.add_development_dependency 'tzinfo-data'

spec.add_dependency 'faraday', '~> 1.1'
spec.add_dependency 'faraday_middleware', '~> 1.0'
Expand Down
5 changes: 3 additions & 2 deletions lib/kubeclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ def delete_entity(resource_name, name, namespace = nil, delete_options: {})
# :orphan_dependents (bool) - should the dependent objects be orphaned
# :propagation_policy (string) - one of Foreground|Background|Orphan
# :resource_version (string) - sets a limit on the resource versions that can be served
# :resource_version_match (string) - determines how the resource_version constraint will be applied
# :resource_version_match (string) - determines how the resource_version constraint
# will be applied.
# :timeout_seconds (integer) - limits the duraiton of the call
# :continue (string) - a token used to retrieve the next chunk of entities
# :as (:raw|:ros) - defaults to :ros
Expand Down Expand Up @@ -761,7 +762,7 @@ def http_options(uri)
http_proxy_uri: @http_proxy_uri,
http_max_redirects: http_max_redirects,
bearer_token_file: @auth_options[:bearer_token_file],
bearer_token: @auth_options[:bearer_token],
bearer_token: @auth_options[:bearer_token]
}

if uri.scheme == 'https'
Expand Down
19 changes: 11 additions & 8 deletions test/test_watch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ def test_watch_pod_api_bearer_token_file_success
watcher = client.watch_pods(as: :raw)

begin
file.write("valid_token")
file.write('valid_token')
file.rewind
stub_token = stub_request(:get, %r{/watch/pods})
.with(headers: { Authorization: 'Bearer valid_token' })
.to_return(body: open_test_file('watch_stream.json'), status: 200)
.with(headers: { Authorization: 'Bearer valid_token' })
.to_return(body: open_test_file('watch_stream.json'), status: 200)

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

file.write("rotated_token")
file.write('rotated_token')
file.close
stub_request(:get, %r{/watch/pods})
.with(headers: { Authorization: 'Bearer rotated_token' })
Expand All @@ -134,8 +134,8 @@ def test_watch_pod_api_bearer_token_file_success
watcher.each { |notice| got = notice }
assert_match(/\A{"type":"DELETED"/, got)
ensure
file.close
file.unlink # deletes the temp file
file.close
file.unlink # deletes the temp file
end
end

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

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

got = nil
client.watch_pods(as: :raw).each { |notice| got = notice }
assert_match(/\A{"type":"DELETED"/, got)
ensure
file.close
file.unlink # deletes the temp file
end

# Ensure that WatchStream respects a format that's not JSON
Expand Down