@@ -28,17 +28,17 @@ pub enum Error {
28
28
}
29
29
30
30
/// Build RBAC objects for the product workloads.
31
- /// The `rbac_prefix ` is meant to be the product name, for example: zookeeper, airflow, etc.
32
- /// and it is a assumed that a ClusterRole named `{rbac_prefix }-clusterrole` exists.
33
- /// 'rbac_prefix ' is not used to build the names of the serviceAccount and roleBinding objects,
31
+ /// The `product_name ` is meant to be the product name, for example: zookeeper, airflow, etc.
32
+ /// and it is a assumed that a ClusterRole named `{product_name }-clusterrole` exists.
33
+ /// 'product_name ' is not used to build the names of the serviceAccount and roleBinding objects,
34
34
/// as this caused problems with multiple clusters of the same product within the same namespace
35
35
/// see <https://stackable.atlassian.net/browse/SUP-148> for more details.
36
36
/// Instead the names for these objects are created by reading the name from the cluster object
37
37
/// and appending [-rolebinding|-serviceaccount] to create unique names instead of using the
38
38
/// same objects for multiple clusters.
39
39
pub fn build_rbac_resources < T : Clone + Resource < DynamicType = ( ) > > (
40
40
resource : & T ,
41
- rbac_prefix : & str ,
41
+ product_name : & str ,
42
42
labels : Labels ,
43
43
) -> Result < ( ServiceAccount , RoleBinding ) > {
44
44
let sa_name = service_account_name ( & resource. name_any ( ) ) ;
@@ -67,7 +67,7 @@ pub fn build_rbac_resources<T: Clone + Resource<DynamicType = ()>>(
67
67
. build ( ) ,
68
68
role_ref : RoleRef {
69
69
kind : "ClusterRole" . to_string ( ) ,
70
- name : format ! ( "{rbac_prefix }-clusterrole" ) ,
70
+ name : format ! ( "{product_name }-clusterrole" ) ,
71
71
api_group : "rbac.authorization.k8s.io" . to_string ( ) ,
72
72
} ,
73
73
subjects : Some ( vec ! [ Subject {
@@ -83,13 +83,19 @@ pub fn build_rbac_resources<T: Clone + Resource<DynamicType = ()>>(
83
83
84
84
/// Generate the service account name.
85
85
/// The `rbac_prefix` is meant to be the product name, for example: zookeeper, airflow, etc.
86
- pub fn service_account_name ( rbac_prefix : & str ) -> String {
86
+ /// This is private because operators should not use this function to calculate names for
87
+ /// serviceAccount objects, but rather read the name from the objects returned by
88
+ /// `build_rbac_resources` if they need the name.
89
+ fn service_account_name ( rbac_prefix : & str ) -> String {
87
90
format ! ( "{rbac_prefix}-serviceaccount" )
88
91
}
89
92
90
93
/// Generate the role binding name.
91
94
/// The `rbac_prefix` is meant to be the product name, for example: zookeeper, airflow, etc.
92
- pub fn role_binding_name ( rbac_prefix : & str ) -> String {
95
+ /// This is private because operators should not use this function to calculate names for
96
+ /// roleBinding objects, but rather read the name from the objects returned by
97
+ /// `build_rbac_resources` if they need the name.
98
+ fn role_binding_name ( rbac_prefix : & str ) -> String {
93
99
format ! ( "{rbac_prefix}-rolebinding" )
94
100
}
95
101
0 commit comments