From da2f51d46f968f446ab7c7111c38811e4149e19e Mon Sep 17 00:00:00 2001 From: andrussal Date: Sun, 8 Mar 2026 13:32:10 +0100 Subject: [PATCH] Make attach source construction explicit --- .../core/src/scenario/sources/model.rs | 22 +++++++------------ .../deployers/compose/src/deployer/mod.rs | 10 +++++++-- .../compose/src/deployer/orchestrator.rs | 2 +- .../deployers/k8s/src/deployer/mod.rs | 5 ++++- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/testing-framework/core/src/scenario/sources/model.rs b/testing-framework/core/src/scenario/sources/model.rs index 0e14091..0a3dc69 100644 --- a/testing-framework/core/src/scenario/sources/model.rs +++ b/testing-framework/core/src/scenario/sources/model.rs @@ -21,13 +21,10 @@ impl AttachSource { } #[must_use] - pub fn with_namespace(self, namespace: String) -> Self { - match self { - Self::K8s { label_selector, .. } => Self::K8s { - namespace: Some(namespace), - label_selector, - }, - other => other, + pub fn k8s_in_namespace(label_selector: String, namespace: String) -> Self { + Self::K8s { + namespace: Some(namespace), + label_selector, } } @@ -40,13 +37,10 @@ impl AttachSource { } #[must_use] - pub fn with_project(self, project: String) -> Self { - match self { - Self::Compose { services, .. } => Self::Compose { - project: Some(project), - services, - }, - other => other, + pub fn compose_in_project(services: Vec, project: String) -> Self { + Self::Compose { + project: Some(project), + services, } } } diff --git a/testing-framework/deployers/compose/src/deployer/mod.rs b/testing-framework/deployers/compose/src/deployer/mod.rs index 60a88de..2f809c7 100644 --- a/testing-framework/deployers/compose/src/deployer/mod.rs +++ b/testing-framework/deployers/compose/src/deployer/mod.rs @@ -50,7 +50,10 @@ impl ComposeDeploymentMetadata { .project_name() .ok_or(ComposeMetadataError::MissingProjectName)?; - Ok(AttachSource::compose(Vec::new()).with_project(project_name.to_owned())) + Ok(AttachSource::compose_in_project( + Vec::new(), + project_name.to_owned(), + )) } /// Builds an attach source for the same compose project. @@ -62,7 +65,10 @@ impl ComposeDeploymentMetadata { .project_name() .ok_or(ComposeMetadataError::MissingProjectName)?; - Ok(AttachSource::compose(services).with_project(project_name.to_owned())) + Ok(AttachSource::compose_in_project( + services, + project_name.to_owned(), + )) } } diff --git a/testing-framework/deployers/compose/src/deployer/orchestrator.rs b/testing-framework/deployers/compose/src/deployer/orchestrator.rs index 831f3fe..ddd88f0 100644 --- a/testing-framework/deployers/compose/src/deployer/orchestrator.rs +++ b/testing-framework/deployers/compose/src/deployer/orchestrator.rs @@ -321,7 +321,7 @@ impl DeploymentOrchestrator { fn managed_cluster_wait(&self, project_name: String) -> Arc> { Arc::new(ComposeAttachedClusterWait::::new( compose_runner_host(), - AttachSource::compose(Vec::new()).with_project(project_name), + AttachSource::compose_in_project(Vec::new(), project_name), )) } diff --git a/testing-framework/deployers/k8s/src/deployer/mod.rs b/testing-framework/deployers/k8s/src/deployer/mod.rs index e16ec45..43f0ff5 100644 --- a/testing-framework/deployers/k8s/src/deployer/mod.rs +++ b/testing-framework/deployers/k8s/src/deployer/mod.rs @@ -41,6 +41,9 @@ impl K8sDeploymentMetadata { .label_selector() .ok_or(K8sMetadataError::MissingLabelSelector)?; - Ok(AttachSource::k8s(label_selector.to_owned()).with_namespace(namespace.to_owned())) + Ok(AttachSource::k8s_in_namespace( + label_selector.to_owned(), + namespace.to_owned(), + )) } }