From 05d5676fd035839905d760e124e9851e148c3530 Mon Sep 17 00:00:00 2001 From: Max Lambrecht Date: Sat, 9 Mar 2024 16:41:48 -0600 Subject: [PATCH 1/4] Add missing Debug implementations Signed-off-by: Max Lambrecht --- spiffe/src/workload_api/client.rs | 3 +-- spiffe/src/workload_api/x509_source.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/spiffe/src/workload_api/client.rs b/spiffe/src/workload_api/client.rs index 7e7b31e..b3e2b71 100644 --- a/spiffe/src/workload_api/client.rs +++ b/spiffe/src/workload_api/client.rs @@ -83,8 +83,7 @@ const SPIFFE_HEADER_VALUE: &str = "true"; /// Supports one-shot calls and streaming updates for X.509 and JWT SVIDs and bundles. /// The client can be used to fetch the current SVIDs and bundles, as well as to /// subscribe for updates whenever the SVIDs or bundles change. -#[allow(missing_debug_implementations)] -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct WorkloadApiClient { client: SpiffeWorkloadApiClient< tonic::service::interceptor::InterceptedService, diff --git a/spiffe/src/workload_api/x509_source.rs b/spiffe/src/workload_api/x509_source.rs index 3566198..456d2b9 100644 --- a/spiffe/src/workload_api/x509_source.rs +++ b/spiffe/src/workload_api/x509_source.rs @@ -61,6 +61,7 @@ use crate::workload_api::client::WorkloadApiClient; use crate::workload_api::x509_context::X509Context; use log::{debug, error, info}; use std::error::Error; +use std::fmt::Debug; use std::sync::{Arc, PoisonError, RwLock}; use thiserror::Error; use tokio::sync::watch; @@ -80,6 +81,8 @@ use tokio_util::sync::CancellationToken; /// ``` /// use spiffe::svid::x509::X509Svid; /// use spiffe::workload_api::x509_source::SvidPicker; +/// +/// #[derive(Debug)] /// struct SecondSvidPicker; /// /// impl SvidPicker for SecondSvidPicker { @@ -88,7 +91,7 @@ use tokio_util::sync::CancellationToken; /// } /// } /// ``` -pub trait SvidPicker: Send + Sync { +pub trait SvidPicker: Send + Sync + Debug { /// Selects an `X509Svid` from the provided slice of `X509Svid`. /// /// # Parameters @@ -131,7 +134,7 @@ impl X509SourceError { /// `X509Source` implements the [`BundleSource`] and [`SvidSource`] traits. /// /// The methods return cloned instances of the underlying objects. -#[allow(missing_debug_implementations)] +#[derive(Debug)] pub struct X509Source { svid: RwLock>, bundles: RwLock>, @@ -144,7 +147,7 @@ pub struct X509Source { } /// Builder for `X509Source`. -#[allow(missing_debug_implementations)] +#[derive(Debug)] pub struct X509SourceBuilder { client: Option, svid_picker: Option>, @@ -162,6 +165,7 @@ pub struct X509SourceBuilder { /// use spiffe::workload_api::x509_source::{SvidPicker, X509SourceBuilder}; /// use std::error::Error; /// +/// #[derive(Debug)] /// struct SecondSvidPicker; /// /// impl SvidPicker for SecondSvidPicker { From 8066f752a599452c49e22c309488fed8b090528d Mon Sep 17 00:00:00 2001 From: Max Lambrecht Date: Sat, 9 Mar 2024 16:45:57 -0600 Subject: [PATCH 2/4] Minor amend Signed-off-by: Max Lambrecht --- spiffe/src/workload_api/x509_source.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spiffe/src/workload_api/x509_source.rs b/spiffe/src/workload_api/x509_source.rs index 456d2b9..544a722 100644 --- a/spiffe/src/workload_api/x509_source.rs +++ b/spiffe/src/workload_api/x509_source.rs @@ -91,7 +91,7 @@ use tokio_util::sync::CancellationToken; /// } /// } /// ``` -pub trait SvidPicker: Send + Sync + Debug { +pub trait SvidPicker: Send + Sync + Debug { /// Selects an `X509Svid` from the provided slice of `X509Svid`. /// /// # Parameters From d20e6dd31f93282e584ee9b2c416a679c8dfd862 Mon Sep 17 00:00:00 2001 From: Max Lambrecht Date: Sat, 9 Mar 2024 17:06:31 -0600 Subject: [PATCH 3/4] Add missing debug Signed-off-by: Max Lambrecht --- spiffe/tests/x509_source_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/spiffe/tests/x509_source_tests.rs b/spiffe/tests/x509_source_tests.rs index ce7978a..ab937cd 100644 --- a/spiffe/tests/x509_source_tests.rs +++ b/spiffe/tests/x509_source_tests.rs @@ -21,6 +21,7 @@ mod integration_tests_x509_source { static TRUST_DOMAIN: Lazy = Lazy::new(|| TrustDomain::new("example.org").unwrap()); + #[derive(Debug)] struct SecondSvidPicker; impl SvidPicker for SecondSvidPicker { From b310686a3c4ef91832c9b49bc1ba192f7ac54d33 Mon Sep 17 00:00:00 2001 From: Max Lambrecht Date: Sat, 9 Mar 2024 17:24:15 -0600 Subject: [PATCH 4/4] Reorder traits Signed-off-by: Max Lambrecht --- spiffe/src/workload_api/x509_source.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spiffe/src/workload_api/x509_source.rs b/spiffe/src/workload_api/x509_source.rs index 544a722..11397fd 100644 --- a/spiffe/src/workload_api/x509_source.rs +++ b/spiffe/src/workload_api/x509_source.rs @@ -91,7 +91,7 @@ use tokio_util::sync::CancellationToken; /// } /// } /// ``` -pub trait SvidPicker: Send + Sync + Debug { +pub trait SvidPicker: Debug + Send + Sync { /// Selects an `X509Svid` from the provided slice of `X509Svid`. /// /// # Parameters