Skip to content

Commit 6e7d60f

Browse files
committed
rename default to is_default to work around possible progenitor bug
1 parent 1c047dc commit 6e7d60f

File tree

12 files changed

+27
-26
lines changed

12 files changed

+27
-26
lines changed

nexus/db-model/src/ip_pool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ pub struct IpPool {
4949
/// Project, if IP pool is associated with a particular project
5050
pub project_id: Option<Uuid>,
5151

52-
pub default: bool,
52+
pub is_default: bool,
5353
}
5454

5555
impl IpPool {
5656
pub fn new(
5757
pool_identity: &external::IdentityMetadataCreateParams,
5858
silo_id: Option<Uuid>,
59-
default: bool,
59+
is_default: bool,
6060
) -> Self {
6161
Self {
6262
identity: IpPoolIdentity::new(
@@ -66,7 +66,7 @@ impl IpPool {
6666
rcgen: 0,
6767
silo_id,
6868
project_id: None,
69-
default,
69+
is_default,
7070
}
7171
}
7272
}

nexus/db-model/src/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ table! {
455455
rcgen -> Int8,
456456
silo_id -> Nullable<Uuid>,
457457
project_id -> Nullable<Uuid>,
458-
default -> Bool,
458+
is_default -> Bool,
459459
}
460460
}
461461

nexus/db-queries/src/db/datastore/ip_pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl DataStore {
9191
.filter(
9292
dsl::project_id.eq(project_id).or(dsl::project_id.is_null()),
9393
)
94-
.filter(dsl::default.eq(true))
94+
.filter(dsl::is_default.eq(true))
9595
.filter(dsl::time_deleted.is_null())
9696
// this will sort by most specific first, i.e.,
9797
//
@@ -479,7 +479,7 @@ mod test {
479479
.unwrap();
480480

481481
assert_eq!(fleet_default_pool.identity.name.as_str(), "default");
482-
assert!(fleet_default_pool.default);
482+
assert!(fleet_default_pool.is_default);
483483
assert_eq!(fleet_default_pool.silo_id, None);
484484
assert_eq!(fleet_default_pool.project_id, None);
485485

nexus/src/app/ip_pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl super::Nexus {
6969
let pool = db::model::IpPool::new(
7070
&pool_params.identity,
7171
silo_id,
72-
pool_params.default,
72+
pool_params.is_default,
7373
);
7474
self.db_datastore.ip_pool_create(opctx, pool).await
7575
}

nexus/test-utils/src/resource_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub async fn create_ip_pool(
141141
description: String::from("an ip pool"),
142142
},
143143
silo: None,
144-
default: false,
144+
is_default: false,
145145
},
146146
)
147147
.await;

nexus/tests/integration_tests/endpoints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ lazy_static! {
456456
},
457457
silo: None,
458458
// TODO: this might error due to the unique index
459-
default: true,
459+
is_default: true,
460460
};
461461
pub static ref DEMO_IP_POOL_PROJ_URL: String =
462462
format!("/v1/ip-pools/{}?project={}", *DEMO_IP_POOL_NAME, *DEMO_PROJECT_NAME);

nexus/tests/integration_tests/ip_pools.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async fn test_ip_pool_basic_crud(cptestctx: &ControlPlaneTestContext) {
104104
description: String::from(description),
105105
},
106106
silo: None,
107-
default: false,
107+
is_default: false,
108108
};
109109
let created_pool: IpPool =
110110
NexusRequest::objects_post(client, ip_pools_url, &params)
@@ -284,7 +284,7 @@ async fn test_ip_pool_with_silo(cptestctx: &ControlPlaneTestContext) {
284284
description: String::from(""),
285285
},
286286
silo: Some(NameOrId::Name(cptestctx.silo_name.clone())),
287-
default: false,
287+
is_default: false,
288288
};
289289
let created_pool = create_pool(client, &params).await;
290290
assert_eq!(created_pool.identity.name, "p0");
@@ -299,7 +299,7 @@ async fn test_ip_pool_with_silo(cptestctx: &ControlPlaneTestContext) {
299299
description: String::from(""),
300300
},
301301
silo: Some(NameOrId::Id(silo_id)),
302-
default: false,
302+
is_default: false,
303303
};
304304
let created_pool = create_pool(client, &params).await;
305305
assert_eq!(created_pool.identity.name, "p1");
@@ -314,7 +314,7 @@ async fn test_ip_pool_with_silo(cptestctx: &ControlPlaneTestContext) {
314314
silo: Some(NameOrId::Name(
315315
String::from("not-a-thing").parse().unwrap(),
316316
)),
317-
default: false,
317+
is_default: false,
318318
};
319319
let error: HttpErrorResponseBody = NexusRequest::new(
320320
RequestBuilder::new(client, Method::POST, "/v1/system/ip-pools")
@@ -373,7 +373,7 @@ async fn test_ip_pool_range_overlapping_ranges_fails(
373373
description: String::from(description),
374374
},
375375
silo: None,
376-
default: false,
376+
is_default: false,
377377
};
378378
let created_pool: IpPool =
379379
NexusRequest::objects_post(client, ip_pools_url, &params)
@@ -556,7 +556,7 @@ async fn test_ip_pool_range_pagination(cptestctx: &ControlPlaneTestContext) {
556556
description: String::from(description),
557557
},
558558
silo: None,
559-
default: false,
559+
is_default: false,
560560
};
561561
let created_pool: IpPool =
562562
NexusRequest::objects_post(client, ip_pools_url, &params)
@@ -694,7 +694,7 @@ async fn test_ip_pool_list_usable_by_project(
694694
description: String::from("right on cue"),
695695
},
696696
silo: None,
697-
default: false,
697+
is_default: false,
698698
};
699699
NexusRequest::objects_post(client, ip_pools_url, &params)
700700
.authn_as(AuthnMode::PrivilegedUser)

nexus/types/src/external_api/params.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,8 @@ pub struct IpPoolCreate {
736736
/// silo can draw from that pool.
737737
pub silo: Option<NameOrId>,
738738

739-
pub default: bool,
739+
#[serde(default)]
740+
pub is_default: bool,
740741
}
741742

742743
/// Parameters for updating an IP Pool

openapi/nexus.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10169,12 +10169,13 @@
1016910169
"description": "Create-time parameters for an `IpPool`",
1017010170
"type": "object",
1017110171
"properties": {
10172-
"default": {
10173-
"type": "boolean"
10174-
},
1017510172
"description": {
1017610173
"type": "string"
1017710174
},
10175+
"is_default": {
10176+
"default": false,
10177+
"type": "boolean"
10178+
},
1017810179
"name": {
1017910180
"$ref": "#/components/schemas/Name"
1018010181
},
@@ -10189,7 +10190,6 @@
1018910190
}
1019010191
},
1019110192
"required": [
10192-
"default",
1019310193
"description",
1019410194
"name"
1019510195
]

schema/crdb/3.0.0/up.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SELECT CAST(
1212
);
1313

1414
ALTER TABLE omicron.public.ip_pool
15-
ADD COLUMN IF NOT EXISTS "default" BOOLEAN NOT NULL DEFAULT FALSE,
15+
ADD COLUMN IF NOT EXISTS is_default BOOLEAN NOT NULL DEFAULT FALSE,
1616

1717
ADD COLUMN IF NOT EXISTS silo_ID UUID,
1818
ADD COLUMN IF NOT EXISTS project_id UUID,
@@ -42,6 +42,6 @@ CREATE UNIQUE INDEX IF NOT EXISTS one_default_pool_per_scope ON omicron.public.i
4242
COALESCE(silo_id, '00000000-0000-0000-0000-000000000000'::uuid),
4343
COALESCE(project_id, '00000000-0000-0000-0000-000000000000'::uuid)
4444
) WHERE
45-
"default" = true AND time_deleted IS NULL;
45+
is_default = true AND time_deleted IS NULL;
4646

4747
COMMIT;

0 commit comments

Comments
 (0)