Make attach source construction explicit

This commit is contained in:
andrussal 2026-03-08 13:32:10 +01:00
parent 23838867c2
commit da2f51d46f
4 changed files with 21 additions and 18 deletions

View File

@ -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<String>, project: String) -> Self {
Self::Compose {
project: Some(project),
services,
}
}
}

View File

@ -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(),
))
}
}

View File

@ -321,7 +321,7 @@ impl<E: ComposeDeployEnv> DeploymentOrchestrator<E> {
fn managed_cluster_wait(&self, project_name: String) -> Arc<dyn ClusterWaitHandle<E>> {
Arc::new(ComposeAttachedClusterWait::<E>::new(
compose_runner_host(),
AttachSource::compose(Vec::new()).with_project(project_name),
AttachSource::compose_in_project(Vec::new(), project_name),
))
}

View File

@ -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(),
))
}
}