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

Request: support arbitrary subresources #487

Merged
merged 2 commits into from
Apr 10, 2021

Conversation

MikailBag
Copy link
Contributor

This PR only changes low-level Request; Api is left untouched.

This way users can work with exotic subresources (such as certificatesigningrequests/approval) without directly manipulating URLs.

@clux
Copy link
Member

clux commented Apr 6, 2021

Looks reasonable to me. You're only breaking Request and not Api.

Do you think we should maybe add generic helpers for it ala Api::get_subresource::<U> in Api with an extra generic parameter for the output type?

@clux
Copy link
Member

clux commented Apr 10, 2021

Just to clarify, I am completely happy with this, and thank you!

But I do think we should have the same support in Api:

let api: Api<Pod> = Api::namespaced(..)
api::patch_subresource::<Scale>("scale", "mypod", PatchParams, Patch);
api::get_subresource::<Scale>("scale", "mypod");
api::replace_subresource::<Scale>("scale", "mypod", PostParams, data);

even though it looks like the generic types on these 3 methods would overlap in the CSR case as the approval response looks like it's a CSR again:

let api: Api<CertificateSigningRequest> = Api::all(..)
api::patch_subresource::<CertificateSigningRequest>("approval", "mycsr", PatchParams, Patch);
api::get_subresource::<CertificateSigningRequest>("approval", "mycsr");
api::replace_subresource::<CertificateSigningRequest>("approval", "mycsr", PostParams, data);

@clux
Copy link
Member

clux commented Apr 10, 2021

That said, the double string parameter is a bit ugly. Maybe we should leave it in Request for now.

As a follow-up, happy with PRs doing the above, or creating a cheap subresource shortcut (ala scale) for CSRs explicitly in Api.

@clux clux merged commit 1f2aad1 into kube-rs:master Apr 10, 2021
@clux clux mentioned this pull request Apr 10, 2021
11 tasks
@clux
Copy link
Member

clux commented May 15, 2021

Released in 0.53.0. Thanks again.

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.

2 participants