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

Create APIResource from ApiResource for extension an APIService #1195

Closed
wants to merge 2 commits into from
Closed

Create APIResource from ApiResource for extension an APIService #1195

wants to merge 2 commits into from

Conversation

suryapandian
Copy link
Contributor

@suryapandian suryapandian commented Apr 9, 2023

Motivation

Tries to address #1194
This seems too easy that I am sure this is not what you had in mind. What did you have in mind?

  1. they have one version, while kube-rs has api_version and version. 
 I am guessing we need to match version with kube-rs’s api-version.
  2. hard coding verbs with vec!["list".to_string(), "get".to_string()], feels wrong, is that okay?

The example above is converting using the Resource trait, but that is actually insufficient (hence the manually supplied verbs).

So, I guess it's okay

Solution

Signed-off-by: suryapandian <suryamailsyou@gmail.com>
@suryapandian
Copy link
Contributor Author

test cases are failing even tho this is trivial 🤔

@suryapandian suryapandian marked this pull request as ready for review April 9, 2023 20:45
@codecov
Copy link

codecov bot commented Apr 9, 2023

Codecov Report

Merging #1195 (51fa34a) into main (3e788bb) will increase coverage by 0.11%.
The diff coverage is 95.83%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1195      +/-   ##
==========================================
+ Coverage   73.42%   73.54%   +0.11%     
==========================================
  Files          68       68              
  Lines        5370     5394      +24     
==========================================
+ Hits         3943     3967      +24     
  Misses       1427     1427              
Impacted Files Coverage Δ
kube-core/src/discovery.rs 97.34% <95.83%> (-0.41%) ⬇️

... and 1 file with indirect coverage changes

@clux
Copy link
Member

clux commented Apr 9, 2023

Thanks for looking into this. However, turns out, this is actually a little harder than I first thought :(

Currently, not all the information we need is currently in ApiResource as the struct is currently split into two (ApiResource + ApiCapabilities) and these two are usually returned together via discovery.

So together; ApiResource + ApiCapabilities
should combine to APIResource.

However writing an impl Into<APIResource> for (ApiResource, ApiCapabilities) is not the greatest interface.
Seeing that this is currently impossible to do cleanly, we need to wait until we resolve: #1038

Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

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

Nits. Although you won't actually be able to proceed at the moment. I have accidentally mislead you with a "good first issue". Sorry.

Comment on lines 64 to 66
group: Option::from(self.group),
kind: self.kind,
version: Option::from(self.api_version),
Copy link
Member

Choose a reason for hiding this comment

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

These first 3 are correct. Although I'd use Some(self.group) etc.

You are missing name which comes from self.plural.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could Some but what if it had empty string?

Copy link
Member

Choose a reason for hiding this comment

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

empty string is a legal group name

group: Option::from(self.group),
kind: self.kind,
version: Option::from(self.api_version),
namespaced: true,
Copy link
Member

Choose a reason for hiding this comment

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

needs to look at ApiCapabilites::scope currently

kind: self.kind,
version: Option::from(self.api_version),
namespaced: true,
verbs: vec!["list".to_string(), "get".to_string()],
Copy link
Member

Choose a reason for hiding this comment

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

would come from ApiCapabilities::subresources

@clux clux linked an issue Apr 9, 2023 that may be closed by this pull request
@clux clux added blocked awaiting upstream work changelog-add changelog added category for prs labels Apr 9, 2023
Signed-off-by: suryapandian <suryamailsyou@gmail.com>
@suryapandian
Copy link
Contributor Author

Nits. Although you won't actually be able to proceed at the moment. I have accidentally mislead you with a "good first issue". Sorry.

that's okay. happens 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked awaiting upstream work changelog-add changelog added category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create APIResource from ApiResource for extension an APIService
2 participants