Skip to content

Commit 0f46373

Browse files
committed
delete Role, RoleName, RolePage views and params
1 parent cbd6d81 commit 0f46373

File tree

3 files changed

+4
-142
lines changed

3 files changed

+4
-142
lines changed

common/src/api/external/mod.rs

Lines changed: 3 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -495,72 +495,6 @@ fn name_schema(
495495
.into()
496496
}
497497

498-
/// Name for a built-in role
499-
#[derive(
500-
Clone,
501-
Debug,
502-
DeserializeFromStr,
503-
Display,
504-
Eq,
505-
FromStr,
506-
Ord,
507-
PartialEq,
508-
PartialOrd,
509-
SerializeDisplay,
510-
)]
511-
#[display("{resource_type}.{role_name}")]
512-
pub struct RoleName {
513-
// "resource_type" is generally the String value of one of the
514-
// `ResourceType` variants. We could store the parsed `ResourceType`
515-
// instead, but it's useful to be able to represent RoleNames for resource
516-
// types that we don't know about. That could happen if we happen to find
517-
// them in the database, for example.
518-
#[from_str(regex = "[a-z-]+")]
519-
resource_type: String,
520-
#[from_str(regex = "[a-z-]+")]
521-
role_name: String,
522-
}
523-
524-
impl RoleName {
525-
pub fn new(resource_type: &str, role_name: &str) -> RoleName {
526-
RoleName {
527-
resource_type: String::from(resource_type),
528-
role_name: String::from(role_name),
529-
}
530-
}
531-
}
532-
533-
/// Custom JsonSchema implementation to encode the constraints on RoleName
534-
impl JsonSchema for RoleName {
535-
fn schema_name() -> String {
536-
"RoleName".to_string()
537-
}
538-
fn json_schema(
539-
_: &mut schemars::gen::SchemaGenerator,
540-
) -> schemars::schema::Schema {
541-
schemars::schema::Schema::Object(schemars::schema::SchemaObject {
542-
metadata: Some(Box::new(schemars::schema::Metadata {
543-
title: Some("A name for a built-in role".to_string()),
544-
description: Some(
545-
"Role names consist of two string components \
546-
separated by dot (\".\")."
547-
.to_string(),
548-
),
549-
..Default::default()
550-
})),
551-
instance_type: Some(schemars::schema::SingleOrVec::Single(
552-
Box::new(schemars::schema::InstanceType::String),
553-
)),
554-
string: Some(Box::new(schemars::schema::StringValidation {
555-
max_length: Some(63),
556-
min_length: None,
557-
pattern: Some("[a-z-]+\\.[a-z-]+".to_string()),
558-
})),
559-
..Default::default()
560-
})
561-
}
562-
}
563-
564498
/// Byte count to express memory or storage capacity.
565499
//
566500
// The maximum supported byte count is [`i64::MAX`]. This makes it somewhat
@@ -1040,6 +974,7 @@ pub enum ResourceType {
1040974
RouterRoute,
1041975
Oximeter,
1042976
MetricProducer,
977+
RoleBuiltin,
1043978
TufRepo,
1044979
TufArtifact,
1045980
SwitchPort,
@@ -3324,8 +3259,8 @@ mod test {
33243259
use super::VpcFirewallRuleHostFilter;
33253260
use super::VpcFirewallRuleTarget;
33263261
use super::{
3327-
ByteCount, Digest, L4Port, L4PortRange, Name, RoleName,
3328-
VpcFirewallRuleAction, VpcFirewallRuleDirection, VpcFirewallRuleFilter,
3262+
ByteCount, Digest, L4Port, L4PortRange, Name, VpcFirewallRuleAction,
3263+
VpcFirewallRuleDirection, VpcFirewallRuleFilter,
33293264
VpcFirewallRulePriority, VpcFirewallRuleProtocol,
33303265
VpcFirewallRuleStatus, VpcFirewallRuleUpdate,
33313266
VpcFirewallRuleUpdateParams,
@@ -3408,54 +3343,6 @@ mod test {
34083343
}
34093344
}
34103345

3411-
#[test]
3412-
fn test_role_name_parse() {
3413-
// Error cases
3414-
let bad_inputs = vec![
3415-
// empty string is always worth testing
3416-
"",
3417-
// missing dot
3418-
"project",
3419-
// extra dot (or, illegal character in the second component)
3420-
"project.admin.super",
3421-
// missing resource type (or, another bogus resource type)
3422-
".admin",
3423-
// missing role name
3424-
"project.",
3425-
// illegal characters in role name
3426-
"project.not_good",
3427-
];
3428-
3429-
for input in bad_inputs {
3430-
eprintln!("check name {:?} (expecting error)", input);
3431-
let result =
3432-
input.parse::<RoleName>().expect_err("unexpectedly succeeded");
3433-
eprintln!("(expected) error: {:?}", result);
3434-
}
3435-
3436-
eprintln!("check name \"project.admin\" (expecting success)");
3437-
let role_name =
3438-
"project.admin".parse::<RoleName>().expect("failed to parse");
3439-
assert_eq!(role_name.to_string(), "project.admin");
3440-
assert_eq!(role_name.resource_type, "project");
3441-
assert_eq!(role_name.role_name, "admin");
3442-
3443-
eprintln!("check name \"barf.admin\" (expecting success)");
3444-
let role_name =
3445-
"barf.admin".parse::<RoleName>().expect("failed to parse");
3446-
assert_eq!(role_name.to_string(), "barf.admin");
3447-
assert_eq!(role_name.resource_type, "barf");
3448-
assert_eq!(role_name.role_name, "admin");
3449-
3450-
eprintln!("check name \"organization.super-user\" (expecting success)");
3451-
let role_name = "organization.super-user"
3452-
.parse::<RoleName>()
3453-
.expect("failed to parse");
3454-
assert_eq!(role_name.to_string(), "organization.super-user");
3455-
assert_eq!(role_name.resource_type, "organization");
3456-
assert_eq!(role_name.role_name, "super-user");
3457-
}
3458-
34593346
#[test]
34603347
fn test_resource_name_parse() {
34613348
let bad_inputs = vec![

nexus/types/src/external_api/params.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,22 +2398,6 @@ pub struct AllowListUpdate {
23982398
pub allowed_ips: AllowedSourceIps,
23992399
}
24002400

2401-
// Roles
2402-
2403-
// Roles have their own pagination scheme because they do not use the usual "id"
2404-
// or "name" types. For more, see the comment in dbinit.sql.
2405-
#[derive(Deserialize, JsonSchema, Serialize)]
2406-
pub struct RolePage {
2407-
pub last_seen: String,
2408-
}
2409-
2410-
/// Path parameters for global (system) role requests
2411-
#[derive(Deserialize, JsonSchema)]
2412-
pub struct RolePath {
2413-
/// The built-in role's unique name.
2414-
pub role_name: String,
2415-
}
2416-
24172401
// Console API
24182402

24192403
#[derive(Deserialize, JsonSchema)]

nexus/types/src/external_api/views.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use daft::Diffable;
1515
use omicron_common::api::external::{
1616
AffinityPolicy, AllowedSourceIps as ExternalAllowedSourceIps, ByteCount,
1717
Digest, Error, FailureDomain, IdentityMetadata, InstanceState, Name,
18-
ObjectIdentity, RoleName, SimpleIdentity, SimpleIdentityOrName,
18+
ObjectIdentity, SimpleIdentity, SimpleIdentityOrName,
1919
};
2020
use omicron_uuid_kinds::{AlertReceiverUuid, AlertUuid};
2121
use oxnet::{Ipv4Net, Ipv6Net};
@@ -963,15 +963,6 @@ pub struct UserBuiltin {
963963
pub identity: IdentityMetadata,
964964
}
965965

966-
// ROLES
967-
968-
/// View of a Role
969-
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, JsonSchema)]
970-
pub struct Role {
971-
pub name: RoleName,
972-
pub description: String,
973-
}
974-
975966
// SSH KEYS
976967

977968
/// View of an SSH Key

0 commit comments

Comments
 (0)