Skip to content

Commit 11e92c4

Browse files
committed
chore: nullify unimplemented environments; demonstrate environment selection.
1 parent 982d2bf commit 11e92c4

File tree

7 files changed

+47
-64
lines changed

7 files changed

+47
-64
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ mtma-environment-types = { path = "environments/util/types" }
222222
### core
223223
mtma-testing-environment = { path = "environments/core/testing" }
224224
mtma-provisioner-environment = { path = "environments/core/provisioner" }
225-
mtma-box-environment = { path = "environments/box/provisioner" }
225+
mtma-box-environment = { path = "environments/core/box" }
226226

227227
[workspace.lints.clippy]
228228
debug_assert_with_mut_call = "deny"
Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use anyhow::Context;
2-
use movement_core::Overlays;
31
use mtma_environment_types::{EnvironmentError, Environmentish};
42
use mtma_migrator_types::migrator::MovementMigrator;
53
use std::fmt::Debug;
@@ -27,32 +25,6 @@ impl BoxEnvironment {
2725

2826
impl Environmentish for BoxEnvironment {
2927
async fn build_movement_migrator(&self) -> Result<MovementMigrator, EnvironmentError> {
30-
// Form the migrator.
31-
let mut movement_migrator =
32-
MovementMigrator::try_temp().map_err(|e| BoxEnvironmentError::Internal(e.into()))?;
33-
movement_migrator.set_overlays(Overlays::default());
34-
35-
// Start the migrator so that it's running in the background.
36-
// In the future, some migrators may be for already running nodes.
37-
let movement_migrator_for_task = movement_migrator.clone();
38-
let movement_migrator_task = kestrel::task(async move {
39-
movement_migrator_for_task.run().await?;
40-
Ok::<_, anyhow::Error>(())
41-
});
42-
43-
// wait for the rest client to be ready
44-
// once we have this, there should also be a config, so we can then kill off the migrator and proceed
45-
movement_migrator
46-
.wait_for_rest_client_ready(tokio::time::Duration::from_secs(600)) // we wait for up to ten minutes because the nix flake in .vendors/movementcan be a bit slow the first time
47-
.await
48-
.context(
49-
"failed to wait for movement migrator rest client while running accounts equal manual prelude",
50-
).map_err(|e| BoxEnvironmentError::Internal(e.into()))?;
51-
52-
kestrel::end!(movement_migrator_task)
53-
.context("failed to end movement migrator task")
54-
.map_err(|e| BoxEnvironmentError::Internal(e.into()))?;
55-
56-
Ok(movement_migrator)
28+
Err(BoxEnvironmentError::Internal(anyhow::anyhow!("not implemented").into()).into())
5729
}
5830
}
Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use anyhow::Context;
2-
use movement_core::Overlays;
31
use mtma_environment_types::{EnvironmentError, Environmentish};
42
use mtma_migrator_types::migrator::MovementMigrator;
53
use std::fmt::Debug;
@@ -27,32 +25,6 @@ impl ProvisionerEnvironment {
2725

2826
impl Environmentish for ProvisionerEnvironment {
2927
async fn build_movement_migrator(&self) -> Result<MovementMigrator, EnvironmentError> {
30-
// Form the migrator.
31-
let mut movement_migrator = MovementMigrator::try_temp()
32-
.map_err(|e| ProvisionerEnvironmentError::Internal(e.into()))?;
33-
movement_migrator.set_overlays(Overlays::default());
34-
35-
// Start the migrator so that it's running in the background.
36-
// In the future, some migrators may be for already running nodes.
37-
let movement_migrator_for_task = movement_migrator.clone();
38-
let movement_migrator_task = kestrel::task(async move {
39-
movement_migrator_for_task.run().await?;
40-
Ok::<_, anyhow::Error>(())
41-
});
42-
43-
// wait for the rest client to be ready
44-
// once we have this, there should also be a config, so we can then kill off the migrator and proceed
45-
movement_migrator
46-
.wait_for_rest_client_ready(tokio::time::Duration::from_secs(600)) // we wait for up to ten minutes because the nix flake in .vendors/movementcan be a bit slow the first time
47-
.await
48-
.context(
49-
"failed to wait for movement migrator rest client while running accounts equal manual prelude",
50-
).map_err(|e| ProvisionerEnvironmentError::Internal(e.into()))?;
51-
52-
kestrel::end!(movement_migrator_task)
53-
.context("failed to end movement migrator task")
54-
.map_err(|e| ProvisionerEnvironmentError::Internal(e.into()))?;
55-
56-
Ok(movement_migrator)
28+
Err(ProvisionerEnvironmentError::Internal(anyhow::anyhow!("not implemented").into()).into())
5729
}
5830
}

migration/cli/migrate-node/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ tracing = { workspace = true }
3434
tracing-subscriber = { workspace = true }
3535
slect = { workspace = true }
3636
mtma-testing-environment = { workspace = true }
37+
mtma-box-environment = { workspace = true }
38+
mtma-provisioner-environment = { workspace = true }
3739
mtma-environment-types = { workspace = true }
3840
mtma-migrator-types = { workspace = true }
3941

migration/cli/migrate-node/docs/cli/README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,35 @@ Select migration over the node
125125
###### **Options:**
126126

127127
* `--environment-testing` — Enable the environment-testing selection
128+
* `--environment-box` — Enable the environment-box selection
129+
* `--environment-provisioner` — Enable the environment-provisioner selection
128130
* `--null` — Enable the null selection
129131

130-
**Selection (1/2):** `environment-testing`
132+
**Selection (1/4):** `environment-testing`
131133
The config for the [TestingEnvironment]
132134

133135
Usage: --environment-testing.*
134136

135137
Options:
136138
-h, --help Print help (see more with '--help')
137139

138-
**Selection (2/2):** `null`
140+
**Selection (2/4):** `environment-box`
141+
The config for the [BoxEnvironment]
142+
143+
Usage: --environment-box.*
144+
145+
Options:
146+
-h, --help Print help (see more with '--help')
147+
148+
**Selection (3/4):** `environment-provisioner`
149+
The config for the [ProvisionerEnvironment]
150+
151+
Usage: --environment-provisioner.*
152+
153+
Options:
154+
-h, --help Print help (see more with '--help')
155+
156+
**Selection (4/4):** `null`
139157
The config for the migration
140158

141159
Usage: --null.*

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use anyhow::Context;
22
use clap::Parser;
3+
use mtma_box_environment::Config as BoxEnvironmentConfig;
34
use mtma_environment_types::Environmentish;
45
use mtma_migrator_types::migration::Migrationish;
56
use mtma_node_null_core::Config as NullConfig;
7+
use mtma_provisioner_environment::Config as ProvisionerEnvironmentConfig;
68
use mtma_testing_environment::Config as TestingEnvironmentConfig;
79
use serde::{Deserialize, Serialize};
810
use slect::Slect;
@@ -12,14 +14,29 @@ use slect::Slect;
1214
#[clap(help_expected = true)]
1315
pub struct Select {
1416
/// Extra args to pass to slect API
15-
#[slect(environment_testing = TestingEnvironmentConfig, null = NullConfig)]
17+
#[slect(environment_testing = TestingEnvironmentConfig, environment_box = BoxEnvironmentConfig, environment_provisioner = ProvisionerEnvironmentConfig, null = NullConfig)]
1618
extra_args: Vec<String>,
1719
}
1820

1921
impl select::Select {
2022
pub async fn execute(&self) -> Result<(), anyhow::Error> {
21-
let (maybe_environment_testing, maybe_null) =
22-
self.select().map_err(|e| anyhow::anyhow!("{}", e))?;
23+
let (
24+
maybe_environment_testing,
25+
maybe_environment_box,
26+
maybe_environment_provisioner,
27+
maybe_null,
28+
) = self.select().map_err(|e| anyhow::anyhow!("{}", e))?;
29+
30+
// if more than one environment is provided, we need to error
31+
let environment_count = maybe_environment_testing.is_some() as u8
32+
+ maybe_environment_box.is_some() as u8
33+
+ maybe_environment_provisioner.is_some() as u8;
34+
if environment_count > 1 {
35+
return Err(anyhow::anyhow!(
36+
"only one environment should be provided, but got {}",
37+
environment_count
38+
));
39+
}
2340

2441
let environment_config = maybe_environment_testing.context(
2542
"--environment-testing is the only supported environment; it must be provided",

0 commit comments

Comments
 (0)