@@ -7,13 +7,19 @@ use stackable_operator::{
77 kvp:: ObjectLabels ,
88 product_logging:: framework:: VECTOR_CONFIG_FILE ,
99 role_utils:: RoleGroupRef ,
10+ utils:: cluster_info:: KubernetesClusterInfo ,
11+ v2:: builder:: meta:: ownerreference_from_resource,
1012} ;
1113
1214use crate :: {
1315 controller:: {
14- build:: properties:: {
15- ConfigFileName , authorizers, bootstrap_conf, logging, login_identity_providers,
16- nifi_properties, security_properties, state_management_xml,
16+ build:: {
17+ git_sync,
18+ properties:: {
19+ ConfigFileName , authorizers, bootstrap_conf, logging, login_identity_providers,
20+ nifi_properties, security_properties, state_management_xml,
21+ } ,
22+ proxy_hosts,
1723 } ,
1824 validate:: ValidatedCluster ,
1925 } ,
@@ -22,11 +28,6 @@ use crate::{
2228
2329#[ derive( Debug , Snafu ) ]
2430pub enum Error {
25- #[ snafu( display( "object is missing metadata to build owner reference" ) ) ]
26- ObjectMissingMetadataForOwnerRef {
27- source : stackable_operator:: builder:: meta:: Error ,
28- } ,
29-
3031 #[ snafu( display( "failed to build metadata" ) ) ]
3132 MetadataBuild {
3233 source : stackable_operator:: builder:: meta:: Error ,
@@ -62,30 +63,25 @@ pub enum Error {
6263 source : crate :: security:: authentication:: Error ,
6364 } ,
6465
65- #[ snafu( display( "object has no nodes defined" ) ) ]
66- NoNodesDefined ,
67-
6866 #[ snafu( display( "the cluster has no rolegroup [{role_group}] in role [{role}]" ) ) ]
6967 MissingRoleGroup { role : String , role_group : String } ,
7068
71- #[ snafu( display( "missing git-sync resources for rolegroup [{role_group}] " ) ) ]
72- MissingGitSyncResources { role_group : String } ,
69+ #[ snafu( display( "failed to build git-sync resources" ) ) ]
70+ BuildGitSyncResources { source : git_sync :: Error } ,
7371}
7472
7573type Result < T , E = Error > = std:: result:: Result < T , E > ;
7674
7775/// Build the rolegroup [`ConfigMap`] configuring the rolegroup based on the
7876/// resolved cluster configuration.
7977///
80- /// All NiFi configuration is sourced from `cluster`. The only use of `owner` is for
81- /// the OwnerReference, `name_and_namespace`, and the raw role spec used for JVM
82- /// argument merging. `recommended_labels` must be built by the caller (typically via
83- /// `build_recommended_labels`).
78+ /// All NiFi configuration is sourced from `cluster`. `recommended_labels` must be built by the
79+ /// caller (typically via `build_recommended_labels`).
8480pub fn build_rolegroup_config_map (
8581 cluster : & ValidatedCluster ,
8682 rolegroup : & RoleGroupRef < v1alpha1:: NifiCluster > ,
8783 recommended_labels : & ObjectLabels < ' _ , v1alpha1:: NifiCluster > ,
88- owner : & v1alpha1 :: NifiCluster ,
84+ cluster_info : & KubernetesClusterInfo ,
8985) -> Result < ConfigMap > {
9086 tracing:: debug!( "building rolegroup ConfigMap" ) ;
9187
@@ -99,24 +95,20 @@ pub fn build_rolegroup_config_map(
9995 } ) ?;
10096
10197 // The raw role spec is only needed for JVM argument merging in `bootstrap_conf`.
102- let role = owner . spec . nodes . as_ref ( ) . context ( NoNodesDefinedSnafu ) ? ;
98+ let role = & cluster . nodes ;
10399
104- let git_sync_resources = cluster
105- . git_sync_resources
106- . get ( & rolegroup. role_group )
107- . with_context ( || MissingGitSyncResourcesSnafu {
108- role_group : rolegroup. role_group . clone ( ) ,
109- } ) ?;
100+ let proxy_hosts = proxy_hosts:: compute_proxy_hosts ( cluster, cluster_info) ;
101+ let git_sync_resources =
102+ git_sync:: build_git_sync_resources ( cluster, rg) . context ( BuildGitSyncResourcesSnafu ) ?;
110103
111104 let mut cm_builder = ConfigMapBuilder :: new ( ) ;
112105
113106 cm_builder
114107 . metadata (
115108 ObjectMetaBuilder :: new ( )
116- . name_and_namespace ( owner )
109+ . namespace ( & cluster . namespace )
117110 . name ( rolegroup. object_name ( ) )
118- . ownerreference_from_resource ( owner, None , Some ( true ) )
119- . context ( ObjectMissingMetadataForOwnerRefSnafu ) ?
111+ . ownerreference ( ownerreference_from_resource ( cluster, None , Some ( true ) ) )
120112 . with_recommended_labels ( recommended_labels)
121113 . context ( MetadataBuildSnafu ) ?
122114 . build ( ) ,
@@ -133,11 +125,11 @@ pub fn build_rolegroup_config_map(
133125 )
134126 . add_data (
135127 ConfigFileName :: NifiProperties . to_string ( ) ,
136- nifi_properties:: build ( cluster, rg, git_sync_resources) . with_context ( |_| {
137- BuildNifiPropertiesSnafu {
128+ nifi_properties:: build ( cluster, rg, & proxy_hosts , & git_sync_resources) . with_context (
129+ |_| BuildNifiPropertiesSnafu {
138130 rolegroup : rolegroup. clone ( ) ,
139- }
140- } ) ?,
131+ } ,
132+ ) ?,
141133 )
142134 . add_data (
143135 ConfigFileName :: StateManagementXml . to_string ( ) ,
@@ -150,9 +142,7 @@ pub fn build_rolegroup_config_map(
150142 )
151143 . add_data (
152144 ConfigFileName :: Authorizers . to_string ( ) ,
153- // TODO: authorizers::build currently takes a raw &NifiCluster; once migrated
154- // to ValidatedCluster this `owner` arg can be removed.
155- authorizers:: build ( cluster, owner) ,
145+ authorizers:: build ( cluster) ,
156146 )
157147 . add_data (
158148 ConfigFileName :: SecurityProperties . to_string ( ) ,
0 commit comments