Skip to content

Commit

Permalink
use consistent naming of scope structs
Browse files Browse the repository at this point in the history
Signed-off-by: clux <sszynrae@gmail.com>
  • Loading branch information
clux committed Jul 20, 2022
1 parent 42d8ad8 commit 4af062b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions kube-client/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub use kube_core::{
watch::WatchEvent,
Resource, ResourceExt,
};
use kube_core::{DynamicScope, NamespaceResourceScope};
use kube_core::{DynamicResourceScope, NamespaceResourceScope};
pub use params::{
DeleteParams, ListParams, Patch, PatchParams, PostParams, Preconditions, PropagationPolicy,
ValidationDirective,
Expand Down Expand Up @@ -81,7 +81,7 @@ impl<K: Resource> Api<K> {
/// This function accepts `K::DynamicType` so it can be used with dynamic resources.
pub fn namespaced_with(client: Client, ns: &str, dyntype: &K::DynamicType) -> Self
where
K: Resource<Scope = DynamicScope>,
K: Resource<Scope = DynamicResourceScope>,
{
// TODO: inspect dyntype scope to verify somehow?
let url = K::url_path(dyntype, Some(ns));
Expand All @@ -102,7 +102,7 @@ impl<K: Resource> Api<K> {
/// namespace when deployed in-cluster.
pub fn default_namespaced_with(client: Client, dyntype: &K::DynamicType) -> Self
where
K: Resource<Scope = DynamicScope>,
K: Resource<Scope = DynamicResourceScope>,
{
let ns = client.default_ns().to_string();
Self::namespaced_with(client, &ns, dyntype)
Expand Down
4 changes: 2 additions & 2 deletions kube-core/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pub use crate::discovery::ApiResource;
use crate::{
metadata::TypeMeta,
resource::{DynamicScope, Resource},
resource::{DynamicResourceScope, Resource},
};
use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
use std::borrow::Cow;
Expand Down Expand Up @@ -60,7 +60,7 @@ impl DynamicObject {

impl Resource for DynamicObject {
type DynamicType = ApiResource;
type Scope = DynamicScope;
type Scope = DynamicResourceScope;

fn group(dt: &ApiResource) -> Cow<'_, str> {
dt.group.as_str().into()
Expand Down
2 changes: 1 addition & 1 deletion kube-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub use request::Request;

mod resource;
pub use resource::{
ClusterResourceScope, DynamicScope, NamespaceResourceScope, Resource, ResourceExt, ResourceScope,
ClusterResourceScope, DynamicResourceScope, NamespaceResourceScope, Resource, ResourceExt, ResourceScope,
SubResourceScope,
};

Expand Down
4 changes: 2 additions & 2 deletions kube-core/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::{
discovery::ApiResource,
metadata::{ListMeta, ObjectMeta, TypeMeta},
resource::{DynamicScope, Resource},
resource::{DynamicResourceScope, Resource},
};
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
Expand Down Expand Up @@ -216,7 +216,7 @@ where
U: Clone,
{
type DynamicType = ApiResource;
type Scope = DynamicScope;
type Scope = DynamicResourceScope;

fn group(dt: &ApiResource) -> Cow<'_, str> {
dt.group.as_str().into()
Expand Down
6 changes: 3 additions & 3 deletions kube-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::{borrow::Cow, collections::BTreeMap};
pub use k8s_openapi::{ClusterResourceScope, NamespaceResourceScope, ResourceScope, SubResourceScope};

/// Indicates that a [`Resource`] is of an indeterminate dynamic scope.
pub struct DynamicScope {}
impl ResourceScope for DynamicScope {}
pub struct DynamicResourceScope {}
impl ResourceScope for DynamicResourceScope {}

/// An accessor trait for a kubernetes Resource.
///
Expand All @@ -36,7 +36,7 @@ pub trait Resource {
/// Type information for the api scope of the resource when known at compile time
///
/// Types from k8s_openapi come with an explicit k8s_openapi::ResourceScope
/// Dynamic types should select `DynamicScope`
/// Dynamic types should select `Scope = DynamicResourceScope`
type Scope;

/// Returns kind of this object
Expand Down

0 comments on commit 4af062b

Please sign in to comment.