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 merge and json patch #390

Merged
merged 1 commit into from
Jan 27, 2019
Merged

Conversation

tsontario
Copy link
Contributor

@tsontario tsontario commented Jan 24, 2019

Closes #357

Following the conversation on #357 and #268 , I figured I could start working on this feature as my first contribution to kubeclient. As @cben proposed, I'm simply adding json_patch_* and merge_patch_* methods to the client.

@tsontario tsontario force-pushed the add_merge_and_json_patch branch from 9a1db32 to 01093e3 Compare January 24, 2019 05:15
Copy link
Collaborator

@cben cben left a comment

Choose a reason for hiding this comment

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

Great work ❤️ Some minor suggestions.

Could you add this to README, including explaining that .patch is strategic merge patch (not obvious from name), that it won't work for custom resources, and a link to https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/ and/or the format RFCs?
And mention in CHANGELOG please (prepend new "Unreleased" section if needed)

@timothysmith0609 timothysmith0609 force-pushed the add_merge_and_json_patch branch from 9a9f80b to c01378c Compare January 24, 2019 13:44

patch = [
{ 'op' => 'replace', 'path' => '/metadata/annotations/key1', 'value' => 'value' },
{ 'op' => 'add', 'path' => '/metadata/annotations/key2', 'value' => 'value' }
Copy link
Collaborator

Choose a reason for hiding this comment

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

in principle, once you use functionally different patch here, ideally you'd mock a different return result than service_patch.json. If you don't want that, nor want to patch only /metadata/annotations/key, please add a comment on the to_return saying it's inaccurate result for this patch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Mocked different resources and tested with against a minikube instance. Both merge_patch and json_patch are working as expected and as described in the tests now

@timothysmith0609
Copy link
Contributor

timothysmith0609 commented Jan 24, 2019

Ok, this is ready for another round of review.

  • Updated README
  • Updated CHANGELOG
  • Separate fixtures for different patches
  • Ran fixture tests locally against minikube instance
  • Remove namespace = nil in patch_entity (since it is in fact redundant)

Copy link
Collaborator

@cben cben left a comment

Choose a reason for hiding this comment

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

LGTM 💯 👍

Do you object to squashing the history? of the 14 commits most modify previous changes...

basic test. TODO model in correct behaviour of different patches

refactor

rubocop fixes

Tidy up test

police

namespace mandatory

CHANGELOG + README (incomplete)

Revert namespace is mandatory

separate fixtures for json + merge patch + assert headers in request

README tweak

Police, test bugfix, final README edit

fix last bad test

README typo
@tsontario tsontario force-pushed the add_merge_and_json_patch branch from 140c9c4 to 0f3ab7c Compare January 27, 2019 03:38
@tsontario
Copy link
Contributor Author

Squashed and ready to go. Thanks for the solid feedback and looking forward to the next PR.

@cben cben merged commit cb998b9 into ManageIQ:master Jan 27, 2019
@cben cben mentioned this pull request Mar 3, 2019
@cben
Copy link
Collaborator

cben commented Mar 3, 2019

released in gem 4.3.0.

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.

3 participants