Skip to content

Commit 449effd

Browse files
authored
(3/5) [nexus] Add CRUD implementations for Affinity/Anti-Affinity Groups (#7445)
Pulled out of #7076 Adds auth structures for Affinity/Anti-Affinity Groups, as well as datastore methods for implementing CRUD (Create, Read, Update Delete) methods on these groups.
1 parent e38289b commit 449effd

File tree

11 files changed

+2956
-0
lines changed

11 files changed

+2956
-0
lines changed

common/src/api/external/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ impl<'a> From<&'a Name> for &'a str {
293293
}
294294
}
295295

296+
impl From<Name> for String {
297+
fn from(name: Name) -> Self {
298+
name.0
299+
}
300+
}
301+
296302
/// `Name` instances are comparable like Strings, primarily so that they can
297303
/// be used as keys in trees.
298304
impl<S> PartialEq<S> for Name

nexus/auth/src/authz/api_resources.rs

+16
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,22 @@ authz_resource! {
714714
polar_snippet = InProject,
715715
}
716716

717+
authz_resource! {
718+
name = "AffinityGroup",
719+
parent = "Project",
720+
primary_key = Uuid,
721+
roles_allowed = false,
722+
polar_snippet = InProject,
723+
}
724+
725+
authz_resource! {
726+
name = "AntiAffinityGroup",
727+
parent = "Project",
728+
primary_key = Uuid,
729+
roles_allowed = false,
730+
polar_snippet = InProject,
731+
}
732+
717733
authz_resource! {
718734
name = "InstanceNetworkInterface",
719735
parent = "Instance",

nexus/auth/src/authz/oso_generic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ pub fn make_omicron_oso(log: &slog::Logger) -> Result<OsoInit, anyhow::Error> {
125125
Disk::init(),
126126
Snapshot::init(),
127127
ProjectImage::init(),
128+
AffinityGroup::init(),
129+
AntiAffinityGroup::init(),
128130
Instance::init(),
129131
IpPool::init(),
130132
InstanceNetworkInterface::init(),

0 commit comments

Comments
 (0)