@@ -3,6 +3,7 @@ use clap::Parser;
3
3
use mtma_box_environment:: Config as BoxEnvironmentConfig ;
4
4
use mtma_environment_types:: Environmentish ;
5
5
use mtma_migrator_types:: migration:: Migrationish ;
6
+ use mtma_migrator_types:: migrator:: MovementMigrator ;
6
7
use mtma_node_null_core:: Config as NullConfig ;
7
8
use mtma_provisioner_environment:: Config as ProvisionerEnvironmentConfig ;
8
9
use mtma_testing_environment:: Config as TestingEnvironmentConfig ;
@@ -19,12 +20,12 @@ pub struct Select {
19
20
}
20
21
21
22
impl select:: Select {
22
- pub async fn execute ( & self ) -> Result < ( ) , anyhow:: Error > {
23
+ pub async fn get_movement_migrator ( & self ) -> Result < MovementMigrator , anyhow:: Error > {
23
24
let (
24
25
maybe_environment_testing,
25
26
maybe_environment_box,
26
27
maybe_environment_provisioner,
27
- maybe_null ,
28
+ _maybe_null ,
28
29
) = self . select ( ) . map_err ( |e| anyhow:: anyhow!( "{}" , e) ) ?;
29
30
30
31
// if more than one environment is provided, we need to error
@@ -38,11 +39,51 @@ impl select::Select {
38
39
) ) ;
39
40
}
40
41
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) ) ?;
44
85
45
- let movement_migrator = environment_config . build ( ) ? . build_movement_migrator ( ) . await ?;
86
+ let movement_migrator = self . get_movement_migrator ( ) . await ?;
46
87
47
88
if let Some ( null) = maybe_null {
48
89
let null_migration = null. build ( ) ?;
0 commit comments