@@ -197,12 +197,6 @@ impl ValidatedCluster {
197197 . expect ( "every DruidRole has a validated role config" )
198198 }
199199
200- /// The type-safe role name for a Druid role.
201- pub ( crate ) fn role_name ( role : & DruidRole ) -> RoleName {
202- RoleName :: from_str ( & role. to_string ( ) )
203- . expect ( "a DruidRole always serializes to a valid role name" )
204- }
205-
206200 fn recommended_labels_with (
207201 & self ,
208202 product_version : & ProductVersion ,
@@ -232,7 +226,7 @@ impl ValidatedCluster {
232226
233227 /// Recommended labels for a role-group resource.
234228 pub fn recommended_labels ( & self , role : & DruidRole , role_group_name : & RoleGroupName ) -> Labels {
235- self . recommended_labels_for ( & Self :: role_name ( role) , role_group_name)
229+ self . recommended_labels_for ( & role. into ( ) , role_group_name)
236230 }
237231
238232 /// Recommended labels with the constant [`UNVERSIONED_PRODUCT_VERSION`], for PVC templates
@@ -242,21 +236,12 @@ impl ValidatedCluster {
242236 role : & DruidRole ,
243237 role_group_name : & RoleGroupName ,
244238 ) -> Labels {
245- self . recommended_labels_with (
246- & UNVERSIONED_PRODUCT_VERSION ,
247- & Self :: role_name ( role) ,
248- role_group_name,
249- )
239+ self . recommended_labels_with ( & UNVERSIONED_PRODUCT_VERSION , & role. into ( ) , role_group_name)
250240 }
251241
252242 /// Selector labels matching the pods of a role group.
253243 pub fn role_group_selector ( & self , role : & DruidRole , role_group_name : & RoleGroupName ) -> Labels {
254- role_group_selector (
255- self ,
256- & product_name ( ) ,
257- & Self :: role_name ( role) ,
258- role_group_name,
259- )
244+ role_group_selector ( self , & product_name ( ) , & role. into ( ) , role_group_name)
260245 }
261246
262247 /// Returns an [`ObjectMetaBuilder`] pre-filled with the namespace, an owner reference back to
@@ -296,7 +281,7 @@ impl ValidatedCluster {
296281 ) -> ResourceNames {
297282 ResourceNames {
298283 cluster_name : self . name . clone ( ) ,
299- role_name : Self :: role_name ( role) ,
284+ role_name : role. into ( ) ,
300285 role_group_name : role_group_name. clone ( ) ,
301286 }
302287 }
@@ -610,11 +595,11 @@ spec:
610595
611596#[ cfg( test) ]
612597mod tests {
613- use stackable_operator:: cli:: OperatorEnvironmentOptions ;
598+ use stackable_operator:: { cli:: OperatorEnvironmentOptions , v2 :: types :: operator :: RoleName } ;
614599 use strum:: IntoEnumIterator ;
615600
616601 use super :: {
617- Error , ValidatedCluster ,
602+ Error ,
618603 test_support:: { MINIMAL_DRUID_YAML , druid_from_yaml} ,
619604 validate,
620605 } ;
@@ -719,12 +704,13 @@ mod tests {
719704 ) ;
720705 }
721706
722- /// Locks the invariant behind the `expect` in [`ValidatedCluster::role_name`]: every
723- /// `DruidRole` variant (present and future) must serialise to a valid `RoleName`.
707+ /// Locks the invariant behind the `expect` in the `From<DruidRole> for RoleName` impls:
708+ /// every `DruidRole` variant (present and future) must serialise to a valid `RoleName`.
724709 #[ test]
725710 fn every_druid_role_serialises_to_a_valid_role_name ( ) {
726711 for role in DruidRole :: iter ( ) {
727- ValidatedCluster :: role_name ( & role) ;
712+ let _: RoleName = ( & role) . into ( ) ;
713+ let _: RoleName = role. into ( ) ;
728714 }
729715 }
730716}
0 commit comments