diff --git a/kube/src/api/resource.rs b/kube/src/api/resource.rs index 04b867c86..82fd42237 100644 --- a/kube/src/api/resource.rs +++ b/kube/src/api/resource.rs @@ -37,8 +37,8 @@ pub enum ResourceScope { // Try Arnavion's first suggestion -pub trait ClusterScopedResource: k8s_openapi::Resource { } -pub trait NamespaceScopedResource: k8s_openapi::Resource { } +pub trait ClusterScopedResource: k8s_openapi::Resource {} +pub trait NamespaceScopedResource: k8s_openapi::Resource {} use k8s::{ admissionregistration::v1beta1 as adregv1beta1, apps::v1 as appsv1, @@ -64,8 +64,9 @@ impl NamespaceScopedResource for appsv1::ReplicaSet {} impl NamespaceScopedResource for networkingv1beta1::Ingress {} impl NamespaceScopedResource for appsv1::DaemonSet {} -use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1 as apiextsv1; -use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1beta1 as apiextsv1beta1; +use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::{ + v1 as apiextsv1, v1beta1 as apiextsv1beta1, +}; impl ClusterScopedResource for storagev1::VolumeAttachment {} impl ClusterScopedResource for adregv1beta1::ValidatingWebhookConfiguration {} @@ -76,7 +77,6 @@ impl ClusterScopedResource for apiextsv1beta1::CustomResourceDefinition {} impl ClusterScopedResource for corev1::Node {} - impl Resource { /// Cluster level resources, pub fn cluster() -> Self { @@ -99,7 +99,7 @@ impl Resource { kind: K::KIND.to_string(), group: K::GROUP.to_string(), version: K::VERSION.to_string(), - scope: ResourceScope::All + scope: ResourceScope::All, } } @@ -833,7 +833,7 @@ mod test { assert_eq!(req.method(), "PUT"); } -/* #[test] + /* #[test] #[should_panic] - compile fails now! fn all_resources_not_namespaceable() { Resource::namespaced::("ns"); diff --git a/kube/src/api/typed.rs b/kube/src/api/typed.rs index 63b883445..703b20122 100644 --- a/kube/src/api/typed.rs +++ b/kube/src/api/typed.rs @@ -29,7 +29,7 @@ pub struct Api { pub(crate) phantom: PhantomData, } -use crate::api::resource::{NamespaceScopedResource, ClusterScopedResource}; +use crate::api::resource::{ClusterScopedResource, NamespaceScopedResource}; /// Expose same interface as Api for controlling scope/group/versions/ns impl Api @@ -38,7 +38,8 @@ where { /// Cluster level resources pub fn cluster(client: Client) -> Self - where K: ClusterScopedResource + where + K: ClusterScopedResource, { let api = Resource::cluster::(); Self { @@ -50,7 +51,8 @@ where /// Namespaced resources viewed across all namespaces pub fn all(client: Client) -> Self - where K: NamespaceScopedResource + where + K: NamespaceScopedResource, { let api = Resource::all::(); Self { @@ -62,7 +64,8 @@ where /// Namespaced resource within a given namespace pub fn namespaced(client: Client, ns: &str) -> Self - where K: NamespaceScopedResource + where + K: NamespaceScopedResource, { let api = Resource::namespaced::(ns); Self {