@@ -3,7 +3,9 @@ use std::str::FromStr;
33use sha2:: { Digest , Sha256 } ;
44
55use super :: types:: {
6- kubernetes:: { ConfigMapName , ListenerName , ServiceName , StatefulSetName } ,
6+ kubernetes:: {
7+ ConfigMapName , DaemonSetName , DeploymentName , ListenerName , ServiceName , StatefulSetName ,
8+ } ,
79 operator:: { ClusterName , RoleGroupName , RoleName } ,
810} ;
911use crate :: attributed_string_type;
@@ -145,6 +147,31 @@ impl ResourceNames {
145147 . expect ( "should be a valid ConfigMap name" )
146148 }
147149
150+ pub fn daemon_set_name ( & self ) -> DaemonSetName {
151+ // compile-time checks
152+ const _: ( ) = assert ! (
153+ QualifiedRoleGroupName :: MAX_LENGTH <= DaemonSetName :: MAX_LENGTH ,
154+ "The string `<qualified_role_group_name>` must not exceed the limit of DaemonSet names."
155+ ) ;
156+ let _ = QualifiedRoleGroupName :: IS_RFC_1123_SUBDOMAIN_NAME ;
157+
158+ DaemonSetName :: from_str ( self . qualified_role_group_name ( ) . as_ref ( ) )
159+ . expect ( "should be a valid DaemonSet name" )
160+ }
161+
162+ pub fn deployment_name ( & self ) -> DeploymentName {
163+ // compile-time checks
164+ const _: ( ) = assert ! (
165+ QualifiedRoleGroupName :: MAX_LENGTH <= DeploymentName :: MAX_LENGTH ,
166+ "The string `<qualified_role_group_name>` must not exceed the limit of Deployment \
167+ names."
168+ ) ;
169+ let _ = QualifiedRoleGroupName :: IS_RFC_1123_LABEL_NAME ;
170+
171+ DeploymentName :: from_str ( self . qualified_role_group_name ( ) . as_ref ( ) )
172+ . expect ( "should be a valid Deployment name" )
173+ }
174+
148175 pub fn stateful_set_name ( & self ) -> StatefulSetName {
149176 // compile-time checks
150177 const _: ( ) = assert ! (
@@ -209,7 +236,10 @@ mod tests {
209236 use super :: { ClusterName , RoleGroupName , RoleName } ;
210237 use crate :: v2:: {
211238 role_group_utils:: { QualifiedRoleGroupName , ResourceNames } ,
212- types:: kubernetes:: { ConfigMapName , ListenerName , ServiceName , StatefulSetName } ,
239+ types:: kubernetes:: {
240+ ConfigMapName , DaemonSetName , DeploymentName , ListenerName , ServiceName ,
241+ StatefulSetName ,
242+ } ,
213243 } ;
214244
215245 #[ test]
@@ -230,6 +260,14 @@ mod tests {
230260 ConfigMapName :: from_str_unsafe( "test-cluster-data-nodes-ssd-storage" ) ,
231261 resource_names. role_group_config_map( )
232262 ) ;
263+ assert_eq ! (
264+ DaemonSetName :: from_str_unsafe( "test-cluster-data-nodes-ssd-storage" ) ,
265+ resource_names. daemon_set_name( )
266+ ) ;
267+ assert_eq ! (
268+ DeploymentName :: from_str_unsafe( "test-cluster-data-nodes-ssd-storage" ) ,
269+ resource_names. deployment_name( )
270+ ) ;
233271 assert_eq ! (
234272 StatefulSetName :: from_str_unsafe( "test-cluster-data-nodes-ssd-storage" ) ,
235273 resource_names. stateful_set_name( )
0 commit comments