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
[PROPOSAL] Add convenience function #66
Comments
These helper methods are definitely useful and I won't have objection adding them. However the approach is not scalable. I would also suggest we go the route of fluent interface that makes things like this easier like this: v1.create_namespaced_pod(
client.V1Pod()
.metadata_name("busy box")
.container_image(0, "busybox")
.container_args(0, ["sleep", "3600"])
.container_name(0, "busy_box")) (fluent interface + expanding internal types + array access fluently) This is not solid yet, just a quick thought. I will write a proposal for it. |
I've had more thoughts on fluent interface, something like this look much better: client.V1Pod()
.edit_metadata()
.name("busy box")
.done()
.add_container()
.image("busybox")
.args(["sleep", "3600"])
.name("busy_box")
.done()
.create() |
|
Maybe, the difference is container is an array, metadata is not. |
@mbohlool, I just want to let you know that I have started working on this, so any notes you have in mind would be welcomed. |
Would be nice if you can share any design before implementation. I added "x-kubernetes-group-version-kind" and "x-kubernetes-action" in Kubernetes 1.7 spec and I was planning to use that to generate a set of kubernetes friendly object with actions on them based on the generated objects. Not a real design, but I was thinking to do have something like: from kubernetes import objects
...
pod = objects.V1Pod() # objects are all in form of GroupVersionKind
or
pod = objects.for_gvk("", "v1", "pod")
# edit pod
pod.create() |
@mbohlool Sorry for the delayed response, I was traveling to Denver for GopherCon 2017 and I am still in Denver for the Conference but I would just like to make some progress on the issue by the time I return to Cameroon. Initialy I was hoping to create helper classes for the resources, which would inherite the exiting classes and then implement helper functions for the fluent interface. Below is a sample for what I had in mind. class PodHelper(V1Pod):
def edit_metadata(self, name=""):
#Create metadata object and set name
return self
def add_container(self, image="", args=[], name="")
#Create container with provided details
return self
def create(self)
#created pod We can then create a pod with client.PodHelper()
.edit_metadata(name="")
.add_container(image="", args=[], name="")
.create() |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
The client is very low level, it would be great to add a few convenience functions ala
kubectl
like:kubectl run
kubectl expose
Right now starting a simple Pod is a bit "complex" and requires digging through the docs quite a bit to find the correct classes to instantiate. For example:
It would be nice to have something like:
The text was updated successfully, but these errors were encountered: