Rename metadata attach flow around existing clusters

This commit is contained in:
andrussal 2026-03-08 14:03:50 +01:00
parent f79eb34a50
commit e04832f62c
5 changed files with 32 additions and 10 deletions

View File

@ -20,7 +20,9 @@ async fn compose_attach_mode_queries_node_api_opt_in() -> Result<()> {
Err(error) => return Err(Error::new(error)),
};
let attach_source = metadata.attach_source().map_err(|err| anyhow!("{err}"))?;
let attach_source = metadata
.existing_cluster()
.map_err(|err| anyhow!("{err}"))?;
let attached = ScenarioBuilder::deployment_with(|d| d.with_node_count(1))
.with_run_duration(Duration::from_secs(5))
.with_existing_cluster(attach_source)

View File

@ -20,7 +20,9 @@ async fn k8s_attach_mode_queries_node_api_opt_in() -> Result<()> {
Err(error) => return Err(Error::new(error)),
};
let attach_source = metadata.attach_source().map_err(|err| anyhow!("{err}"))?;
let attach_source = metadata
.existing_cluster()
.map_err(|err| anyhow!("{err}"))?;
let attached = ScenarioBuilder::deployment_with(|d| d.with_node_count(1))
.with_run_duration(Duration::from_secs(5))
.with_existing_cluster(attach_source)

View File

@ -43,9 +43,9 @@ impl ComposeDeploymentMetadata {
self.project_name.as_deref()
}
/// Builds an attach source for the same compose project using deployer
/// discovery to resolve services.
pub fn attach_source(&self) -> Result<AttachSource, DynError> {
/// Builds an existing-cluster descriptor for the same compose project
/// using deployer discovery to resolve services.
pub fn existing_cluster(&self) -> Result<AttachSource, DynError> {
let project_name = self
.project_name()
.ok_or(ComposeMetadataError::MissingProjectName)?;
@ -56,8 +56,8 @@ impl ComposeDeploymentMetadata {
))
}
/// Builds an attach source for the same compose project.
pub fn attach_source_for_services(
/// Builds an existing-cluster descriptor for the same compose project.
pub fn existing_cluster_for_services(
&self,
services: Vec<String>,
) -> Result<AttachSource, DynError> {
@ -70,6 +70,19 @@ impl ComposeDeploymentMetadata {
project_name.to_owned(),
))
}
#[doc(hidden)]
pub fn attach_source(&self) -> Result<AttachSource, DynError> {
self.existing_cluster()
}
#[doc(hidden)]
pub fn attach_source_for_services(
&self,
services: Vec<String>,
) -> Result<AttachSource, DynError> {
self.existing_cluster_for_services(services)
}
}
impl<E: ComposeDeployEnv> Default for ComposeDeployer<E> {

View File

@ -34,8 +34,8 @@ impl K8sDeploymentMetadata {
self.label_selector.as_deref()
}
/// Builds an attach source for the same k8s deployment scope.
pub fn attach_source(&self) -> Result<AttachSource, DynError> {
/// Builds an existing-cluster descriptor for the same k8s deployment scope.
pub fn existing_cluster(&self) -> Result<AttachSource, DynError> {
let namespace = self.namespace().ok_or(K8sMetadataError::MissingNamespace)?;
let label_selector = self
.label_selector()
@ -46,4 +46,9 @@ impl K8sDeploymentMetadata {
namespace.to_owned(),
))
}
#[doc(hidden)]
pub fn attach_source(&self) -> Result<AttachSource, DynError> {
self.existing_cluster()
}
}

View File

@ -290,7 +290,7 @@ fn managed_cluster_wait<E: K8sDeployEnv>(
) -> Result<Arc<dyn ClusterWaitHandle<E>>, K8sRunnerError> {
let client = client_from_cluster(cluster)?;
let attach_source = metadata
.attach_source()
.existing_cluster()
.map_err(|source| K8sRunnerError::SourceOrchestration { source })?;
Ok(Arc::new(K8sAttachedClusterWait::<E>::new(