Skip to content

Commit 7871287

Browse files
authored
refactor: remove basin creating state (#333)
- remove `Creating` from the basin state enums in common, api, and sdk - update CLI/TUI basin state rendering and basin creation messaging to treat created basins as active - add assertions that created basins return `Active` in lite backend and SDK tests
1 parent f18b061 commit 7871287

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

api/src/v1/basin.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ impl From<types::basin::BasinScope> for BasinScope {
9696
pub enum BasinState {
9797
/// Basin is active.
9898
Active,
99-
/// Basin is being created.
100-
Creating,
10199
/// Basin is being deleted.
102100
Deleting,
103101
}
@@ -106,7 +104,6 @@ impl From<types::basin::BasinState> for BasinState {
106104
fn from(value: types::basin::BasinState) -> Self {
107105
match value {
108106
types::basin::BasinState::Active => Self::Active,
109-
types::basin::BasinState::Creating => Self::Creating,
110107
types::basin::BasinState::Deleting => Self::Deleting,
111108
}
112109
}

cli/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ async fn run() -> Result<(), CliError> {
248248
let info = ops::create_basin(&s2, args).await?;
249249

250250
let message = match info.state {
251-
BasinState::Creating => "✓ Basin creation requested".yellow().bold(),
252251
BasinState::Active => "✓ Basin created".green().bold(),
253252
BasinState::Deleting => "Basin is being deleted".red().bold(),
254253
};
@@ -627,7 +626,6 @@ async fn run() -> Result<(), CliError> {
627626
fn format_basin_state(state: BasinState) -> colored::ColoredString {
628627
match state {
629628
BasinState::Active => "active".green(),
630-
BasinState::Creating => "creating".yellow(),
631629
BasinState::Deleting => "deleting".red(),
632630
}
633631
}

cli/src/tui/ui.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const BORDER_DIM: Color = GRAY_850;
5353
const BORDER_TITLE: Color = GRAY_900;
5454

5555
const BADGE_ACTIVE: Color = Color::Rgb(22, 101, 52);
56-
const BADGE_PENDING: Color = Color::Rgb(113, 63, 18);
5756
const BADGE_DANGER: Color = Color::Rgb(127, 29, 29);
5857

5958
const STAT_MIN: Color = Color::Rgb(96, 165, 250);
@@ -2471,7 +2470,6 @@ fn draw_basins(f: &mut Frame, area: Rect, state: &BasinsState) {
24712470

24722471
let (state_text, state_bg) = match basin.state {
24732472
s2_sdk::types::BasinState::Active => ("Active", BADGE_ACTIVE),
2474-
s2_sdk::types::BasinState::Creating => ("Creating", BADGE_PENDING),
24752473
s2_sdk::types::BasinState::Deleting => ("Deleting", BADGE_DANGER),
24762474
};
24772475

common/src/types/basin.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ pub type ListBasinsRequest = ListItemsRequest<BasinNamePrefix, BasinNameStartAft
202202
#[derive(Debug, Clone, Copy)]
203203
pub enum BasinState {
204204
Active,
205-
Creating,
206205
Deleting,
207206
}
208207

lite/tests/backend/control_plane/basin.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use s2_common::{
99
resources::{CreateMode, ListItemsRequestParts, RequestToken},
1010
},
1111
};
12-
use s2_lite::backend::error::{
13-
CreateBasinError, DeleteBasinError, GetBasinConfigError, ReconfigureBasinError,
12+
use s2_lite::backend::{
13+
CreatedOrReconfigured,
14+
error::{CreateBasinError, DeleteBasinError, GetBasinConfigError, ReconfigureBasinError},
1415
};
1516

1617
use super::common::*;
@@ -26,23 +27,31 @@ async fn test_create_basin_idempotency_respects_request_token() {
2627

2728
let token1: RequestToken = "token-1".parse().unwrap();
2829

29-
backend
30+
let created = backend
3031
.create_basin(
3132
basin_name.clone(),
3233
config.clone(),
3334
CreateMode::CreateOnly(Some(token1.clone())),
3435
)
3536
.await
3637
.expect("Failed to create basin");
38+
assert!(matches!(
39+
created,
40+
CreatedOrReconfigured::Created(ref info) if matches!(info.state, BasinState::Active)
41+
));
3742

38-
backend
43+
let idempotent = backend
3944
.create_basin(
4045
basin_name.clone(),
4146
config.clone(),
4247
CreateMode::CreateOnly(Some(token1.clone())),
4348
)
4449
.await
4550
.expect("Idempotent create should succeed with same request token");
51+
assert!(matches!(
52+
idempotent,
53+
CreatedOrReconfigured::Created(ref info) if matches!(info.state, BasinState::Active)
54+
));
4655

4756
let different_token: RequestToken = "token-2".parse().unwrap();
4857
let different_token_result = backend

sdk/src/types.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,8 +1126,6 @@ impl ListAllBasinsInput {
11261126
pub enum BasinState {
11271127
/// Active
11281128
Active,
1129-
/// Creating
1130-
Creating,
11311129
/// Deleting
11321130
Deleting,
11331131
}
@@ -1136,7 +1134,6 @@ impl From<api::basin::BasinState> for BasinState {
11361134
fn from(value: api::basin::BasinState) -> Self {
11371135
match value {
11381136
api::basin::BasinState::Active => BasinState::Active,
1139-
api::basin::BasinState::Creating => BasinState::Creating,
11401137
api::basin::BasinState::Deleting => BasinState::Deleting,
11411138
}
11421139
}

sdk/tests/account_ops.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async fn create_list_and_delete_basin() -> Result<(), S2Error> {
1616
.await?;
1717

1818
assert_eq!(basin_info.name, basin_name);
19+
assert_eq!(basin_info.state, BasinState::Active);
1920

2021
let page = s2
2122
.list_basins(ListBasinsInput::new().with_prefix(basin_name.clone().into()))

0 commit comments

Comments
 (0)