Skip to content

Commit 77dcbbf

Browse files
committed
chore: upgrade migate-node select to allow use of the box environment.
1 parent 8d33063 commit 77dcbbf

File tree

1 file changed

+47
-6
lines changed
  • migration/cli/migrate-node/src/cli/migrate

1 file changed

+47
-6
lines changed

migration/cli/migrate-node/src/cli/migrate/select.rs

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use clap::Parser;
33
use mtma_box_environment::Config as BoxEnvironmentConfig;
44
use mtma_environment_types::Environmentish;
55
use mtma_migrator_types::migration::Migrationish;
6+
use mtma_migrator_types::migrator::MovementMigrator;
67
use mtma_node_null_core::Config as NullConfig;
78
use mtma_provisioner_environment::Config as ProvisionerEnvironmentConfig;
89
use mtma_testing_environment::Config as TestingEnvironmentConfig;
@@ -19,12 +20,12 @@ pub struct Select {
1920
}
2021

2122
impl select::Select {
22-
pub async fn execute(&self) -> Result<(), anyhow::Error> {
23+
pub async fn get_movement_migrator(&self) -> Result<MovementMigrator, anyhow::Error> {
2324
let (
2425
maybe_environment_testing,
2526
maybe_environment_box,
2627
maybe_environment_provisioner,
27-
maybe_null,
28+
_maybe_null,
2829
) = self.select().map_err(|e| anyhow::anyhow!("{}", e))?;
2930

3031
// if more than one environment is provided, we need to error
@@ -38,11 +39,51 @@ impl select::Select {
3839
));
3940
}
4041

41-
let environment_config = maybe_environment_testing.context(
42-
"--environment-testing is the only supported environment; it must be provided",
43-
)?;
42+
match maybe_environment_testing {
43+
Some(environment_testing) => {
44+
let environment_config = environment_testing.build()?;
45+
return environment_config
46+
.build_movement_migrator()
47+
.await
48+
.map_err(|e| anyhow::anyhow!("{}", e));
49+
}
50+
None => {}
51+
}
52+
53+
match maybe_environment_box {
54+
Some(environment_box) => {
55+
let environment_config = environment_box.build()?;
56+
return environment_config
57+
.build_movement_migrator()
58+
.await
59+
.map_err(|e| anyhow::anyhow!("{}", e));
60+
}
61+
None => {}
62+
}
63+
64+
match maybe_environment_provisioner {
65+
Some(environment_provisioner) => {
66+
let environment_config = environment_provisioner.build()?;
67+
return environment_config
68+
.build_movement_migrator()
69+
.await
70+
.map_err(|e| anyhow::anyhow!("{}", e));
71+
}
72+
None => {}
73+
}
74+
75+
return Err(anyhow::anyhow!("no environment provided"));
76+
}
77+
78+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
79+
let (
80+
_maybe_environment_testing,
81+
_maybe_environment_box,
82+
_maybe_environment_provisioner,
83+
maybe_null,
84+
) = self.select().map_err(|e| anyhow::anyhow!("{}", e))?;
4485

45-
let movement_migrator = environment_config.build()?.build_movement_migrator().await?;
86+
let movement_migrator = self.get_movement_migrator().await?;
4687

4788
if let Some(null) = maybe_null {
4889
let null_migration = null.build()?;

0 commit comments

Comments
 (0)