Git Product home page Git Product logo

Comments (11)

mbohlool avatar mbohlool commented on May 11, 2024

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.

from python.

mbohlool avatar mbohlool commented on May 11, 2024

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

from python.

sebgoa avatar sebgoa commented on May 11, 2024

add_metadata() maybe, it is not really an edit method.

from python.

mbohlool avatar mbohlool commented on May 11, 2024

Maybe, the difference is container is an array, metadata is not.

from python.

djkonro avatar djkonro commented on May 11, 2024

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

from python.

mbohlool avatar mbohlool commented on May 11, 2024

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

from python.

djkonro avatar djkonro commented on May 11, 2024

@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()

from python.

fejta-bot avatar fejta-bot commented on May 11, 2024

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

from python.

fejta-bot avatar fejta-bot commented on May 11, 2024

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

from python.

fejta-bot avatar fejta-bot commented on May 11, 2024

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

from python.

k8s-ci-robot avatar k8s-ci-robot commented on May 11, 2024

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

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.

from python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.