mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-03-31 08:13:48 +00:00
Add semantic existing-cluster constructors
This commit is contained in:
parent
fbede7f535
commit
ad288e7421
@ -73,8 +73,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn attached_sources_are_planned() {
|
||||
let sources = ScenarioSources::default()
|
||||
.with_attach(ExistingCluster::compose(vec!["node-0".to_string()]));
|
||||
let sources =
|
||||
ScenarioSources::default().with_attach(ExistingCluster::for_compose_services(
|
||||
"test-project".to_string(),
|
||||
vec!["node-0".to_string()],
|
||||
));
|
||||
let plan = SourceOrchestrationPlan::try_from_sources(&sources)
|
||||
.expect("attached sources should build a source orchestration plan");
|
||||
|
||||
|
||||
@ -18,8 +18,7 @@ enum ExistingClusterKind {
|
||||
|
||||
impl ExistingCluster {
|
||||
#[must_use]
|
||||
#[doc(hidden)]
|
||||
pub fn k8s(label_selector: String) -> Self {
|
||||
pub fn for_k8s_selector(label_selector: String) -> Self {
|
||||
Self {
|
||||
kind: ExistingClusterKind::K8s {
|
||||
namespace: None,
|
||||
@ -29,8 +28,7 @@ impl ExistingCluster {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[doc(hidden)]
|
||||
pub fn k8s_in_namespace(label_selector: String, namespace: String) -> Self {
|
||||
pub fn for_k8s_selector_in_namespace(namespace: String, label_selector: String) -> Self {
|
||||
Self {
|
||||
kind: ExistingClusterKind::K8s {
|
||||
namespace: Some(namespace),
|
||||
@ -40,19 +38,17 @@ impl ExistingCluster {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[doc(hidden)]
|
||||
pub fn compose(services: Vec<String>) -> Self {
|
||||
pub fn for_compose_project(project: String) -> Self {
|
||||
Self {
|
||||
kind: ExistingClusterKind::Compose {
|
||||
project: None,
|
||||
services,
|
||||
project: Some(project),
|
||||
services: Vec::new(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[doc(hidden)]
|
||||
pub fn compose_in_project(services: Vec<String>, project: String) -> Self {
|
||||
pub fn for_compose_services(project: String, services: Vec<String>) -> Self {
|
||||
Self {
|
||||
kind: ExistingClusterKind::Compose {
|
||||
project: Some(project),
|
||||
|
||||
@ -66,8 +66,7 @@ impl ComposeDeploymentMetadata {
|
||||
.project_name()
|
||||
.ok_or(ComposeMetadataError::MissingProjectName)?;
|
||||
|
||||
Ok(ExistingCluster::compose_in_project(
|
||||
Vec::new(),
|
||||
Ok(ExistingCluster::for_compose_project(
|
||||
project_name.to_owned(),
|
||||
))
|
||||
}
|
||||
@ -81,9 +80,9 @@ impl ComposeDeploymentMetadata {
|
||||
.project_name()
|
||||
.ok_or(ComposeMetadataError::MissingProjectName)?;
|
||||
|
||||
Ok(ExistingCluster::compose_in_project(
|
||||
services,
|
||||
Ok(ExistingCluster::for_compose_services(
|
||||
project_name.to_owned(),
|
||||
services,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@ -53,9 +53,9 @@ impl K8sDeploymentMetadata {
|
||||
.label_selector()
|
||||
.ok_or(K8sMetadataError::MissingLabelSelector)?;
|
||||
|
||||
Ok(ExistingCluster::k8s_in_namespace(
|
||||
label_selector.to_owned(),
|
||||
Ok(ExistingCluster::for_k8s_selector_in_namespace(
|
||||
namespace.to_owned(),
|
||||
label_selector.to_owned(),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user