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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions kube-core/src/discovery.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Type information structs for API discovery
use crate::{gvk::GroupVersionKind, resource::Resource};
use k8s_openapi::apimachinery::pkg::apis::meta::v1::APIResource;
use serde::{Deserialize, Serialize};

/// Information about a Kubernetes API resource
Expand Down Expand Up @@ -57,6 +58,19 @@
}
}

impl Into<APIResource> for ApiResource {
fn into(self) -> APIResource {

Check warning on line 62 in kube-core/src/discovery.rs

View check run for this annotation

Codecov / codecov/patch

kube-core/src/discovery.rs#L62

Added line #L62 was not covered by tests
APIResource {
group: Option::from(self.group),
kind: self.kind,
version: Option::from(self.api_version),

Check warning on line 66 in kube-core/src/discovery.rs

View check run for this annotation

Codecov / codecov/patch

kube-core/src/discovery.rs#L64-L66

Added lines #L64 - L66 were not covered by tests
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

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

verbs: vec!["list".to_string(), "get".to_string()],

Check warning on line 68 in kube-core/src/discovery.rs

View check run for this annotation

Codecov / codecov/patch

kube-core/src/discovery.rs#L68

Added line #L68 was not covered by tests
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

..Default::default()
}
}
}

/// Resource scope
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub enum Scope {
Expand Down