Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tls-srv
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Dec 14, 2022
2 parents 64f2366 + d28a715 commit 8079682
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 30 deletions.
10 changes: 5 additions & 5 deletions kube-client/src/api/core_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ where
/// let pods: Api<Pod> = Api::namespaced(client, "apps");
/// let lp = ListParams::default().labels("app=blog"); // for this app only
/// for p in pods.list(&lp).await? {
/// println!("Found Pod: {}", p.name());
/// println!("Found Pod: {}", p.name_any());
/// }
/// Ok(())
/// }
Expand Down Expand Up @@ -158,7 +158,7 @@ where
/// let pods: Api<Pod> = Api::namespaced(client, "apps");
/// match pods.delete_collection(&DeleteParams::default(), &ListParams::default()).await? {
/// either::Left(list) => {
/// let names: Vec<_> = list.iter().map(ResourceExt::name).collect();
/// let names: Vec<_> = list.iter().map(ResourceExt::name_any).collect();
/// println!("Deleting collection of pods: {:?}", names);
/// },
/// either::Right(status) => {
Expand Down Expand Up @@ -309,9 +309,9 @@ where
/// let mut stream = jobs.watch(&lp, "0").await?.boxed();
/// while let Some(status) = stream.try_next().await? {
/// match status {
/// WatchEvent::Added(s) => println!("Added {}", s.name()),
/// WatchEvent::Modified(s) => println!("Modified: {}", s.name()),
/// WatchEvent::Deleted(s) => println!("Deleted {}", s.name()),
/// WatchEvent::Added(s) => println!("Added {}", s.name_any()),
/// WatchEvent::Modified(s) => println!("Modified: {}", s.name_any()),
/// WatchEvent::Deleted(s) => println!("Deleted {}", s.name_any()),
/// WatchEvent::Bookmark(s) => {},
/// WatchEvent::Error(s) => println!("{}", s),
/// }
Expand Down
8 changes: 4 additions & 4 deletions kube-client/src/discovery/apigroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use std::{cmp::Reverse, collections::HashMap, iter::Iterator};
/// let (ar, caps) = apigroup.recommended_kind("APIService").unwrap();
/// let api: Api<DynamicObject> = Api::all_with(client.clone(), &ar);
/// for service in api.list(&Default::default()).await? {
/// println!("Found APIService: {}", service.name());
/// println!("Found APIService: {}", service.name_any());
/// }
/// Ok(())
/// }
Expand Down Expand Up @@ -227,7 +227,7 @@ impl ApiGroup {
/// }
/// let api: Api<DynamicObject> = Api::all_with(client.clone(), &ar);
/// for inst in api.list(&Default::default()).await? {
/// println!("Found {}: {}", ar.kind, inst.name());
/// println!("Found {}: {}", ar.kind, inst.name_any());
/// }
/// }
/// Ok(())
Expand All @@ -254,7 +254,7 @@ impl ApiGroup {
/// }
/// let api: Api<DynamicObject> = Api::all_with(client.clone(), &ar);
/// for inst in api.list(&Default::default()).await? {
/// println!("Found {}: {}", ar.kind, inst.name());
/// println!("Found {}: {}", ar.kind, inst.name_any());
/// }
/// }
/// Ok(())
Expand Down Expand Up @@ -291,7 +291,7 @@ impl ApiGroup {
/// let (ar, caps) = apigroup.recommended_kind("APIService").unwrap();
/// let api: Api<DynamicObject> = Api::all_with(client.clone(), &ar);
/// for service in api.list(&Default::default()).await? {
/// println!("Found APIService: {}", service.name());
/// println!("Found APIService: {}", service.name_any());
/// }
/// Ok(())
/// }
Expand Down
2 changes: 1 addition & 1 deletion kube-client/src/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Discovery {
/// let api: Api<DynamicObject> = Api::all_with(client.clone(), &ar);
/// // can now api.list() to emulate kubectl get all --all
/// for obj in api.list(&Default::default()).await? {
/// println!("{} {}: {}", ar.api_version, ar.kind, obj.name());
/// println!("{} {}: {}", ar.api_version, ar.kind, obj.name_any());
/// }
/// }
/// }
Expand Down
6 changes: 3 additions & 3 deletions kube-client/src/discovery/oneshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use kube_core::{
/// let (ar, caps) = apigroup.recommended_kind("APIService").unwrap();
/// let api: Api<DynamicObject> = Api::all_with(client.clone(), &ar);
/// for service in api.list(&Default::default()).await? {
/// println!("Found APIService: {}", service.name());
/// println!("Found APIService: {}", service.name_any());
/// }
/// Ok(())
/// }
Expand Down Expand Up @@ -69,7 +69,7 @@ pub async fn group(client: &Client, apigroup: &str) -> Result<ApiGroup> {
/// let (ar, caps) = apigroup.recommended_kind("APIService").unwrap();
/// let api: Api<DynamicObject> = Api::all_with(client.clone(), &ar);
/// for service in api.list(&Default::default()).await? {
/// println!("Found APIService: {}", service.name());
/// println!("Found APIService: {}", service.name_any());
/// }
/// Ok(())
/// }
Expand All @@ -96,7 +96,7 @@ pub async fn pinned_group(client: &Client, gv: &GroupVersion) -> Result<ApiGroup
/// let (ar, caps) = discovery::pinned_kind(&client, &gvk).await?;
/// let api: Api<DynamicObject> = Api::all_with(client.clone(), &ar);
/// for service in api.list(&Default::default()).await? {
/// println!("Found APIService: {}", service.name());
/// println!("Found APIService: {}", service.name_any());
/// }
/// Ok(())
/// }
Expand Down
2 changes: 1 addition & 1 deletion kube-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
//!
//! // List pods in the configured namespace
//! for p in pods.list(&ListParams::default()).await? {
//! println!("found pod {}", p.name());
//! println!("found pod {}", p.name_any());
//! }
//!
//! Ok(())
Expand Down
11 changes: 0 additions & 11 deletions kube-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,6 @@ where

/// Helper methods for resources.
pub trait ResourceExt: Resource {
/// Deprecated fn equivalent to [`name_unchecked`](ResourceExt::name_unchecked)
#[deprecated(
since = "0.74.0",
note = "ResourceExt::name can panic and has been replaced by `ResourceExt::name_any` and `ResourceExt::name_unchecked`. This fn will be removed in 0.77.0."
)]
fn name(&self) -> String;

/// Returns the name of the resource, panicking if it is unset
///
/// Only use this function if you know that name is set; for example when
Expand Down Expand Up @@ -224,10 +217,6 @@ use once_cell::sync::Lazy;
static EMPTY_MAP: Lazy<BTreeMap<String, String>> = Lazy::new(BTreeMap::new);

impl<K: Resource> ResourceExt for K {
fn name(&self) -> String {
self.meta().name.clone().expect(".metadata.name missing")
}

fn name_unchecked(&self) -> String {
self.meta().name.clone().expect(".metadata.name missing")
}
Expand Down
4 changes: 2 additions & 2 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ where
/// .reconcile_all_on(reload_rx.map(|_| ()))
/// .run(
/// |o, _| async move {
/// println!("Reconciling {}", o.name());
/// println!("Reconciling {}", o.name_any());
/// Ok(Action::await_change())
/// },
/// |_object: Arc<ConfigMap>, err: &Infallible, _| Err(err).unwrap(),
Expand Down Expand Up @@ -781,7 +781,7 @@ where
/// .graceful_shutdown_on(tokio::signal::ctrl_c().map(|_| ()))
/// .run(
/// |o, _| async move {
/// println!("Reconciling {}", o.name());
/// println!("Reconciling {}", o.name_any());
/// Ok(Action::await_change())
/// },
/// |_, err: &Infallible, _| Err(err).unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion kube-runtime/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ async fn step<K: Resource + Clone + DeserializeOwned + Debug + Send + 'static>(
///
/// watcher(pods, ListParams::default()).applied_objects()
/// .try_for_each(|p| async move {
/// println!("Applied: {}", p.name());
/// println!("Applied: {}", p.name_any());
/// Ok(())
/// })
/// .await?;
Expand Down
4 changes: 2 additions & 2 deletions kube/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//! // Read pods in the configured namespace into the typed interface from k8s-openapi
//! let pods: Api<Pod> = Api::default_namespaced(client);
//! for p in pods.list(&ListParams::default()).await? {
//! println!("found pod {}", p.name());
//! println!("found pod {}", p.name_any());
//! }
//! Ok(())
//! }
Expand Down Expand Up @@ -90,7 +90,7 @@
//! let lp = ListParams::default();
//! let mut apply_stream = watcher(foos, lp).applied_objects().boxed();
//! while let Some(f) = apply_stream.try_next().await? {
//! println!("saw apply to {}", f.name());
//! println!("saw apply to {}", f.name_any());
//! }
//! Ok(())
//! }
Expand Down

0 comments on commit 8079682

Please sign in to comment.