Skip to content

Commit

Permalink
make fmt..
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Apr 1, 2020
1 parent d71f7aa commit e9cad9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 7 additions & 7 deletions kube/src/api/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {}
Expand All @@ -76,7 +77,6 @@ impl ClusterScopedResource for apiextsv1beta1::CustomResourceDefinition {}
impl ClusterScopedResource for corev1::Node {}



impl Resource {
/// Cluster level resources,
pub fn cluster<K: ClusterScopedResource>() -> Self {
Expand All @@ -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,
}
}

Expand Down Expand Up @@ -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::<corev1::Node>("ns");
Expand Down
11 changes: 7 additions & 4 deletions kube/src/api/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Api<K> {
pub(crate) phantom: PhantomData<K>,
}

use crate::api::resource::{NamespaceScopedResource, ClusterScopedResource};
use crate::api::resource::{ClusterScopedResource, NamespaceScopedResource};

/// Expose same interface as Api for controlling scope/group/versions/ns
impl<K> Api<K>
Expand All @@ -38,7 +38,8 @@ where
{
/// Cluster level resources
pub fn cluster(client: Client) -> Self
where K: ClusterScopedResource
where
K: ClusterScopedResource,
{
let api = Resource::cluster::<K>();
Self {
Expand All @@ -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::<K>();
Self {
Expand All @@ -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::<K>(ns);
Self {
Expand Down

0 comments on commit e9cad9f

Please sign in to comment.