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

Add create, update and delete protocol buffer methods. #71

Merged
merged 3 commits into from
Sep 20, 2017

Conversation

brendandburns
Copy link
Contributor

Finishes off basic protocol buffer support. It's not perfect, but it's usable.

@mbohlool @lwander

* Delete a kubernetes API object using protocol buffer encoding.
* @param builder The builder for the response
* @param path The path to call in the API server
* @return The response received
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe document that delete returns only status and others will return object (if they do)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. (changed the return type)

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the document for return value be the status response? ditto for other methods.

return request(builder, path, "DELETE", null, null, null);
}

/**
* Generic protocol buffer based HTTP request.
* Not intended for general consumption, but public for advance use cases.
* @param builder The appropriate Builder for the object receveived from the request.
* @param method The HTTP method (e.g. GET) for this request.
* @param path The URL path to call (e.g. /api/v1/namespaces/default/pods/pod-name)
* @return A Message of type T
Copy link
Contributor

Choose a reason for hiding this comment

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

add documentation for new fields body, apiVersion, kind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

* @param kind The kind of the object
* @return The response received.
*/
public <T extends Message> ObjectOrStatus<T> create(T obj, String path, String apiVersion, String kind)
Copy link
Contributor

Choose a reason for hiding this comment

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

Until we find a generic way to do it, I suggest we extract apiVersion and kind from T using reflection. I know it is not ideal, but I prefer it vs adding these two parameters to the surface of our proto APIs. ditto for other calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sadly, the fields aren't present in the proto. See the long discussion here:

https://groups.google.com/forum/#!topic/kubernetes-sig-api-machinery/deP_LDaAdVs

Otherwise I would have used reflection.

@mbohlool
Copy link
Contributor

First round of review done. Thanks.

@brendandburns
Copy link
Contributor Author

@mbohlool comments (mostly) addressed, ptal.

Thanks!
--brendan

@mbohlool
Copy link
Contributor

mbohlool commented Sep 17, 2017

@brendandburns I went through that thread about protos and replied there. I think grpc proxy would be nice addition to our generated clients and it could solve the problem of all clients with one generated proxy.

@brendandburns
Copy link
Contributor Author

brendandburns commented Sep 17, 2017 via email

@mbohlool
Copy link
Contributor

Sure.

Copy link
Contributor

@mbohlool mbohlool left a comment

Choose a reason for hiding this comment

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

some more comments but nothing serious.

* Delete a kubernetes API object using protocol buffer encoding.
* @param builder The builder for the response
* @param path The path to call in the API server
* @return The response received
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the document for return value be the status response? ditto for other methods.

* @param kind The kind of the object
* @return The response received.
*/
public <T extends Message> ObjectOrStatus<T> update(T obj, String path, String apiVersion, String kind)
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible for non-delete calls to return status?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, update in particular sometimes returns a 201 (I observed this behavior)

@brendandburns
Copy link
Contributor Author

Tried to address the comments, please take another look.

@mbohlool
Copy link
Contributor

/lgtm I normally squash these type of PRs (when they have merge and duplicate commits and squash all in one commit make sense) to save time instead of asking author to do it. I will do the same here. Please speak up if you don't want me to do in this repo (or ever :) )

@mbohlool mbohlool merged commit dd979d0 into kubernetes-client:master Sep 20, 2017
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