Skip to content

Commit 67eccbc

Browse files
committed
scan VPCs by name, not ID (didn't realize they had names when I started)
1 parent 343fe84 commit 67eccbc

File tree

5 files changed

+6
-26
lines changed

5 files changed

+6
-26
lines changed

omicron-nexus/src/db/datastore.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ use super::schema::Disk;
4848
use super::schema::Instance;
4949
use super::schema::LookupByAttachedInstance;
5050
use super::schema::LookupByUniqueId;
51-
use super::schema::LookupByUniqueIdInProject;
5251
use super::schema::LookupByUniqueName;
5352
use super::schema::LookupByUniqueNameInProject;
5453
use super::schema::Project;
@@ -726,11 +725,11 @@ impl DataStore {
726725
pub async fn project_list_vpcs(
727726
&self,
728727
project_id: &Uuid,
729-
pagparams: &DataPageParams<'_, Uuid>,
728+
pagparams: &DataPageParams<'_, Name>,
730729
) -> ListResult<api::VPC> {
731730
let client = self.pool.acquire().await?;
732731
sql_fetch_page_by::<
733-
LookupByUniqueIdInProject,
732+
LookupByUniqueNameInProject,
734733
VPC,
735734
<VPC as Table>::ModelType,
736735
>(&client, (project_id,), pagparams, VPC::ALL_COLUMNS)

omicron-nexus/src/db/schema.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -399,25 +399,6 @@ impl<'a, R: ResourceTable> LookupKey<'a, R> for LookupByUniqueNameInProject {
399399
}
400400
}
401401

402-
/**
403-
* Implementation of [`LookupKey`] for looking up objects within a project by
404-
* the project_id and the object's id
405-
*/
406-
pub struct LookupByUniqueIdInProject;
407-
impl<'a, R: ResourceTable> LookupKey<'a, R> for LookupByUniqueIdInProject {
408-
type ScopeKey = (&'a Uuid,);
409-
const SCOPE_KEY_COLUMN_NAMES: &'static [&'static str] = &["project_id"];
410-
type ItemKey = Uuid;
411-
const ITEM_KEY_COLUMN_NAME: &'static str = "id";
412-
413-
fn where_select_error(
414-
_scope_key: Self::ScopeKey,
415-
item_key: &Self::ItemKey,
416-
) -> Error {
417-
Error::not_found_by_id(R::RESOURCE_TYPE, item_key)
418-
}
419-
}
420-
421402
/**
422403
* Implementation of [`LookupKey`] for looking up objects by name within the
423404
* scope of an instance (SQL column "attach_instance_id"). This is really just

omicron-nexus/src/http_entrypoints_external.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ async fn instance_disks_delete_disk(
667667
}]
668668
async fn project_vpcs_get(
669669
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
670-
query_params: Query<PaginatedById>,
670+
query_params: Query<PaginatedByName>,
671671
path_params: Path<ProjectPathParam>,
672672
) -> Result<HttpResponseOk<ResultsPage<VPCView>>, HttpError> {
673673
let apictx = rqctx.context();
@@ -682,7 +682,7 @@ async fn project_vpcs_get(
682682
)
683683
.await?;
684684
let view_list = to_view_list(vpc_stream).await;
685-
Ok(HttpResponseOk(ScanById::results_page(&query, view_list)?))
685+
Ok(HttpResponseOk(ScanByName::results_page(&query, view_list)?))
686686
}
687687

688688
/**

omicron-nexus/src/nexus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ impl Nexus {
10051005
pub async fn project_list_vpcs(
10061006
&self,
10071007
project_name: &Name,
1008-
pagparams: &DataPageParams<'_, Uuid>,
1008+
pagparams: &DataPageParams<'_, Name>,
10091009
) -> ListResult<VPC> {
10101010
let project_id =
10111011
self.db_datastore.project_lookup_id_by_name(project_name).await?;

omicron-nexus/tests/output/nexus-openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@
970970
"in": "query",
971971
"name": "sort_by",
972972
"schema": {
973-
"$ref": "#/components/schemas/IdSortMode"
973+
"$ref": "#/components/schemas/NameSortMode"
974974
},
975975
"style": "form"
976976
},

0 commit comments

Comments
 (0)