Skip to content

Conversation

alvaroaleman
Copy link
Member

This change adds subresource apply support to the client. It is breaking, as that entails extending the interface.

The fake client currently only supports the status subresource for apply and will error out if it is used for any other subresource.

Ref #3183

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 20, 2025
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 20, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 20, 2025
@alvaroaleman alvaroaleman added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 20, 2025
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 20, 2025
}

func (sw *fakeSubResourceClient) Apply(ctx context.Context, obj runtime.ApplyConfiguration, opts ...client.SubResourceApplyOption) error {
if sw.subResource != "status" {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is different from Patch, including when using apply through patch which will just patch the main object rather than a subresource when used with subresources other than status.

IMHO it is better to error out rather than to silenly do the wrong thing. We could fo a follow-up to do the same in Patch for consistency (and/or implement the subresources we support through Update there as well)

}

// ApplyOpts applies the given options.
func (ao *SubResourceApplyOptions) ApplyOpts(opts []SubResourceApplyOption) *SubResourceApplyOptions {
Copy link
Member Author

Choose a reason for hiding this comment

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

This differs from our typical naming convention of naming these ApplyOptions because that name is already used for the embedded field. I chose to embedd the field, because there is prior art of doing that in the SubResourcePatchOptions and it seems ergonomical to do it that way, because modifying options doesn't requier to know whether they are defined in ApplyOptions or SubResourceApplyOptions.

@alvaroaleman alvaroaleman mentioned this pull request Sep 5, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants