-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v2.x] Adds raw option for client get requests #271
Conversation
f3477a6
to
d032ca5
Compare
Prevents parsing of response body into Kubeclient objects (Recursive OpenStruct). In large kubernetes cluster environments, it could be implemented by saving off the raw json for later use, which can useful for memory tight scenarios.
lib/kubeclient/common.rb
Outdated
define_singleton_method("get_#{entity.method_names[0]}") do |name, namespace = nil| | ||
get_entity(klass, entity.resource_name, name, namespace) | ||
define_singleton_method("get_#{entity.method_names[0]}") do |name, ns = nil, opts = {}| | ||
get_entity(klass, entity.resource_name, name, ns, opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NickLaMuro the namespace
=> ns
renaming is backward-compatible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the existing functions, this could be kept as namespace
(instead of ns
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
30d73c2
to
dba0ff8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backport LGTM - though there seem to be test failures with test_api_basic_auth_failure_raw
.
lib/kubeclient/common.rb
Outdated
define_singleton_method("get_#{entity.method_names[0]}") do |name, namespace = nil| | ||
get_entity(klass, entity.resource_name, name, namespace) | ||
define_singleton_method("get_#{entity.method_names[0]}") do |name, ns = nil, opts = {}| | ||
get_entity(klass, entity.resource_name, name, ns, opts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the existing functions, this could be kept as namespace
(instead of ns
).
test/test_kubeclient.rb
Outdated
assert_equal(error_message, exception.message) | ||
assert_equal(response, exception.response) | ||
|
||
assert_requested(:get, 'http://localhost:8080/api/v1', times: 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test needs to check against the new URL you changed it to in line 623
(will fix tests):
assert_requested(:get, 'http://username:password@localhost:8080/api/v1', times: 1)
Signed-off-by: Federico Simoncelli <[email protected]>
define_singleton_method("get_#{entity.method_names[0]}") do |name, namespace = nil| | ||
get_entity(klass, entity.resource_name, name, namespace) | ||
define_singleton_method("get_#{entity.method_names[0]}") \ | ||
do |name, namespace = nil, opts = {}| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NickLaMuro could you forward-port this so that master won't have to change to use ns
instead of namespace
?
test/test_kubeclient.rb
Outdated
@@ -457,11 +457,11 @@ def test_get_all_raw | |||
result = client.all_entities(as: :raw) | |||
assert_equal(16, result.keys.size) | |||
|
|||
%w[ | |||
%w( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NickLaMuro would we want to forward-port this as well?
Waiting for @cben and @moolitayer ACK on backward-compatibility. |
ack, LGTM. |
Reverts parts of commit 263ff40 from ManageIQ#271 that restored KubeException - no longer needed after backporting ManageIQ#195 and ManageIQ#233, we now have Kubeclient::HttpError and Kubeclient::ResourceNotFoundError. In other words, v2.x branch is now closer to original ManageIQ#262.
Reverts parts of commit 263ff40 from ManageIQ#271 that restored KubeException - no longer needed after backporting ManageIQ#195 and ManageIQ#233, we now have Kubeclient::HttpError and Kubeclient::ResourceNotFoundError. In other words, v2.x branch is now closer to original ManageIQ#262.
This reverts commit 263ff40 from ManageIQ#271. Those backport changes are no longer needed: - after backporting ManageIQ#195 and ManageIQ#233, v2.x now has Kubeclient::HttpError and Kubeclient::ResourceNotFoundError. - after backporting ManageIQ#247, v2.x now tests with webmock 2.x, it takes `basic_auth` rather than user:pw in URL. - ns/namespace change was just cosmetic. In other words, v2.x branch is now closer to original ManageIQ#262.
This reverts commit 263ff40 from ManageIQ#271. Those backport changes are no longer needed: - after backporting ManageIQ#195 and ManageIQ#233, v2.x now has Kubeclient::HttpError and Kubeclient::ResourceNotFoundError. - after backporting ManageIQ#247, v2.x now tests with webmock 2.x, it takes `basic_auth` rather than user:pw in URL. - ns/namespace change was just cosmetic. In other words, v2.x branch is now closer to original ManageIQ#262.
@NickLaMuro @stefanmb @cben @moolitayer can you review this backport of the raw option to the v2.x branch?
It seemed straight-forward to me and backward compatible (but please double-check that). Let's see if there are any travis failures.
Ref: #262
Thanks.