docs: add custom object patch example - #4868
Open
YuqiGuo105 wants to merge 1 commit into
Open
Conversation
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: YuqiGuo105 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
YuqiGuo105
marked this pull request as ready for review
July 29, 2026 15:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PatchUtilsProblem
The generated
CustomObjectsApiPATCH request defaults toContent-Type: application/json. Kubernetes PATCH endpoints require a patch-specific media type such as:application/json-patch+jsonapplication/merge-patch+jsonCalling the generated request's
execute()method directly can therefore result in415 Unsupported Media Type, even when the patch document itself is valid.Solution
The new
PatchCustomObjectExamplebuilds the generated custom-object request withbuildCall(null)and executes it throughPatchUtils.patch(...):The example reads the patch document from a user-provided file, so it does not assume a particular custom-resource schema or that optional metadata fields already exist.
The generated
CustomObjectsApi.javaand generated API documentation are intentionally left unchanged because those files would be overwritten during OpenAPI regeneration.Tests
PatchUtilsTestnow verifies that custom-object PATCH requests:Content-TypeValidation performed:
./mvnw -pl util,examples/examples-release-latest -am -Dtest=PatchUtilsTest -Dsurefire.failIfNoSpecifiedTests=false test./mvnw spotless:check./mvnw -pl util,examples/examples-release-latest -am clean testCloses #3106.