Skip to content
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

Merged
merged 3 commits into from
Oct 11, 2017

Conversation

simon3z
Copy link
Collaborator

@simon3z simon3z commented Oct 10, 2017

@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.

@simon3z simon3z force-pushed the v2x-as-raw branch 2 times, most recently from f3477a6 to d032ca5 Compare October 10, 2017 09:32
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.
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)
Copy link
Collaborator Author

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?

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).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simon3z @stefanmb This was done because of line length issues for rubocop. Wasn't sure of a better way to do this, and I don't know how concerned you are with rubocop failures (but that did cause the travis run to fail without me doing this).

@simon3z simon3z force-pushed the v2x-as-raw branch 3 times, most recently from 30d73c2 to dba0ff8 Compare October 10, 2017 11:55
Copy link

@stefanmb stefanmb left a 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.

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)

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).

assert_equal(error_message, exception.message)
assert_equal(response, exception.response)

assert_requested(:get, 'http://localhost:8080/api/v1', times: 1)
Copy link
Member

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)

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 = {}|
Copy link
Collaborator Author

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?

@@ -457,11 +457,11 @@ def test_get_all_raw
result = client.all_entities(as: :raw)
assert_equal(16, result.keys.size)

%w[
%w(
Copy link
Collaborator Author

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?

@simon3z
Copy link
Collaborator Author

simon3z commented Oct 11, 2017

Waiting for @cben and @moolitayer ACK on backward-compatibility.

@cben
Copy link
Collaborator

cben commented Oct 11, 2017

ack, LGTM.

@simon3z simon3z merged commit c00170a into ManageIQ:v2.x Oct 11, 2017
cben added a commit to cben/kubeclient that referenced this pull request Jan 22, 2018
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.
cben added a commit to cben/kubeclient that referenced this pull request Jan 22, 2018
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.
cben added a commit to cben/kubeclient that referenced this pull request Jan 22, 2018
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.
cben added a commit to cben/kubeclient that referenced this pull request Jan 25, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants