Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
a CronTab. This example use an example CRD from this tutorial:
https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/

The following yaml manifest has to be applied first:
The following yaml manifest has to be applied first for namespaced scoped CRD:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -72,6 +72,11 @@ def main():
}
}

# patch to update the `spec.cronSpec` field
patch_body = {
"spec": {"cronSpec": "* * * * */10", "image": "my-awesome-cron-image"}
}

# create the resource
api.create_namespaced_custom_object(
group="stable.example.com",
Expand All @@ -93,6 +98,18 @@ def main():
print("Resource details:")
pprint(resource)

# patch the namespaced custom object to update the `spec.cronSpec` field
patch_resource = api.patch_namespaced_custom_object(
group="stable.example.com",
version="v1",
name="my-new-cron-object",
namespace="default",
plural="crontabs",
body=patch_body,
)
print("Resource details:")
pprint(patch_resource)

# delete it
api.delete_namespaced_custom_object(
Copy link
Member

Choose a reason for hiding this comment

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

why do we have a commit that reverse the order of patch_namespaced_custom_object and delete_namespaced_custom_object?

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/kubernetes-client/python/pull/1444/commits is what I was asking for, if that makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept the order like this,
we have create, get, patch, delete

Copy link
Member

@roycaihw roycaihw Apr 30, 2021

Choose a reason for hiding this comment

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

currently the two PRs have the same code change, but the commits are different

Commits should represent meaningful milestones or units of work. Currently the commits in this PR are:

  • your first commit renames the file and adds a patch method after the delete method, which means the example has a bug and will run into an error
  • your second commit reverses the order of the patch method and the delete method to fix the bug in the first commit

please take a look at https://github.com/kubernetes/community/blob/master/contributors/guide/github-workflow.md#squash-commits. The second commit is a "Work in progress" (it fixes a bug in the first commit during development), so please squash it.

again, I think having two commits like the following will be most reasonable and readable:

  • one commit for adding patch example to custom_object.py
  • one commit for renaming the file to namespaced_custom_object.py

at this point I'm also okay with having just one commit, which will be more reasonable than the current two commits in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am keeping the one commit and with proper commit message.

group="stable.example.com",
Expand Down