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 Apply and ApplyStatus methods to dynamic ResourceInterface #109443

Merged
merged 1 commit into from May 4, 2022

Conversation

kevindelgado
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds the Apply and ApplyStatus methods to the dynamic ResourceInterface to mirror the Apply and ApplyStatus methods already available on the typed clients, so that users do not have to manually construct Apply requests as Patch requests.

Which issue(s) this PR fixes:

Fixes #105082

Special notes for your reviewer:

For testing I changed all tests in test/integration/apiserver/apply/... that call dynamicClient#Patch with the apply patch type to use dynamicClient#Apply instead.

This seems like a sufficient way to test it. I didn’t add any testing in the dynamic client fake tests because there aren’t any existing Patch tests that use types.ApplyPatchType (and that’s maybe outside the scope of this PR)

Does this PR introduce a user-facing change?

Adds the `Apply` and `ApplyStatus` methods to the dynamic `ResourceInterface`

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 12, 2022
@k8s-ci-robot k8s-ci-robot requested a review from aojea April 12, 2022 20:32
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 12, 2022
@kevindelgado
Copy link
Contributor Author

I think the only question I have is around whether I did the empty managed fields check correctly (and gave an appropriate error message).

My notes from when we discussed this months ago say that we need to fail if the metadata has any managed fields in it in order to prevent people from passing in a fully-specified unstructured object they got via a read (e.g. dynamicClinet#Get)

/assign @lavalamp as the original requestor of this feature many moons ago
/cc @apelisse

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 12, 2022
}
managedFields := accessor.GetManagedFields()
if len(managedFields) > 0 {
return nil, fmt.Errorf(`cannot apply an object with managed fields already set.
Copy link
Member

Choose a reason for hiding this comment

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

Hopefully the server does this check? (It's OK if the client does it too)

Copy link
Member

Choose a reason for hiding this comment

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

yes it does :-)

Copy link
Member

Choose a reason for hiding this comment

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

@lavalamp
Copy link
Member

This looks good to me!

@lavalamp
Copy link
Member

I'd actually like to backport it but I'm not sure we can claim it's a bug...

@lavalamp
Copy link
Member

/milestone v1.25

@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone Apr 12, 2022
@lavalamp
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kevindelgado, lavalamp

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 lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 12, 2022
@leilajal
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 14, 2022
@k8s-ci-robot k8s-ci-robot merged commit e8ef775 into kubernetes:master May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Apply methods to the dynamic client
5 participants