@@ -67,18 +67,17 @@ use stackable_operator::{
6767use strum:: { EnumDiscriminants , IntoStaticStr } ;
6868
6969use crate :: {
70- controller:: build:: config_map,
70+ controller:: { AirflowRoleGroupConfig , ValidatedCluster , build:: config_map} ,
7171 controller_commons:: { self , CONFIG_VOLUME_NAME , LOG_CONFIG_VOLUME_NAME , LOG_VOLUME_NAME } ,
7272 crd:: {
73- self , APP_NAME , AirflowClusterStatus , AirflowConfig , AirflowConfigOverrides ,
74- AirflowExecutor , AirflowExecutorCommonConfiguration , AirflowRole , CONFIG_PATH , Container ,
75- ExecutorConfig , HTTP_PORT , HTTP_PORT_NAME , LISTENER_VOLUME_DIR , LISTENER_VOLUME_NAME ,
76- LOG_CONFIG_DIR , METRICS_PORT , METRICS_PORT_NAME , OPERATOR_NAME , STACKABLE_LOG_DIR ,
77- TEMPLATE_LOCATION , TEMPLATE_NAME , TEMPLATE_VOLUME_NAME ,
73+ self , APP_NAME , AirflowClusterStatus , AirflowConfigOverrides , AirflowExecutor ,
74+ AirflowExecutorCommonConfiguration , AirflowRole , CONFIG_PATH , Container , ExecutorConfig ,
75+ HTTP_PORT , HTTP_PORT_NAME , LISTENER_VOLUME_DIR , LISTENER_VOLUME_NAME , LOG_CONFIG_DIR ,
76+ METRICS_PORT , METRICS_PORT_NAME , OPERATOR_NAME , STACKABLE_LOG_DIR , TEMPLATE_LOCATION ,
77+ TEMPLATE_NAME , TEMPLATE_VOLUME_NAME ,
7878 authentication:: {
7979 AirflowAuthenticationClassResolved , AirflowClientAuthenticationDetailsResolved ,
8080 } ,
81- authorization:: AirflowAuthorizationResolved ,
8281 build_recommended_labels,
8382 internal_secret:: {
8483 FERNET_KEY_SECRET_KEY , INTERNAL_SECRET_SECRET_KEY , JWT_SECRET_SECRET_KEY ,
@@ -108,106 +107,6 @@ pub struct Ctx {
108107 pub operator_environment : OperatorEnvironmentOptions ,
109108}
110109
111- /// Per-role configuration extracted during validation.
112- #[ derive( Clone , Debug ) ]
113- pub struct ValidatedRoleConfig {
114- pub pdb : Option < stackable_operator:: commons:: pdb:: PdbConfig > ,
115- pub listener_class : Option < String > ,
116- pub group_listener_name : Option < String > ,
117- }
118-
119- /// Per-rolegroup configuration: the merged CRD config plus overrides.
120- ///
121- /// This is the generic [`stackable_operator::v2::role_utils::RoleGroupConfig`]: the merged config
122- /// fragment in `config`, the typed `config_overrides` (role-group merged over role) and the merged
123- /// `env_overrides`/`cli_overrides`/`pod_overrides`. The config overrides are kept typed
124- /// ([`AirflowConfigOverrides`]) and flattened into the rendered config file later, in the build step.
125- pub type AirflowRoleGroupConfig = stackable_operator:: v2:: role_utils:: RoleGroupConfig <
126- AirflowConfig ,
127- stackable_operator:: v2:: role_utils:: GenericCommonConfig ,
128- AirflowConfigOverrides ,
129- > ;
130-
131- /// Cluster-wide configuration that applies to every role and role group.
132- ///
133- /// Carries the dereferenced external references, so every downstream build step reads them from
134- /// here rather than from the raw cluster object.
135- #[ derive( Clone , Debug ) ]
136- pub struct ValidatedClusterConfig {
137- pub executor : AirflowExecutor ,
138- pub authentication_config : AirflowClientAuthenticationDetailsResolved ,
139- pub authorization_config : AirflowAuthorizationResolved ,
140- }
141-
142- /// The validated cluster: proves that config merging succeeded for every role and
143- /// role group before any resources are created.
144- #[ derive( Clone , Debug ) ]
145- pub struct ValidatedCluster {
146- /// `ObjectMeta` carrying `name`, `namespace` and `uid`, captured during validation, so this
147- /// struct can stand in as the owner [`Resource`] for child objects.
148- metadata : ObjectMeta ,
149- pub image : ResolvedProductImage ,
150- pub cluster_config : ValidatedClusterConfig ,
151- pub role_groups : BTreeMap < AirflowRole , BTreeMap < String , AirflowRoleGroupConfig > > ,
152- pub role_configs : BTreeMap < AirflowRole , ValidatedRoleConfig > ,
153- }
154-
155- impl ValidatedCluster {
156- pub fn new (
157- airflow : & v1alpha2:: AirflowCluster ,
158- image : ResolvedProductImage ,
159- cluster_config : ValidatedClusterConfig ,
160- role_groups : BTreeMap < AirflowRole , BTreeMap < String , AirflowRoleGroupConfig > > ,
161- role_configs : BTreeMap < AirflowRole , ValidatedRoleConfig > ,
162- ) -> Self {
163- Self {
164- // Capture only the identity fields needed to own child objects.
165- metadata : ObjectMeta {
166- name : Some ( airflow. name_any ( ) ) ,
167- namespace : airflow. namespace ( ) ,
168- uid : airflow. uid ( ) ,
169- ..ObjectMeta :: default ( )
170- } ,
171- image,
172- cluster_config,
173- role_groups,
174- role_configs,
175- }
176- }
177- }
178-
179- /// Lets [`ValidatedCluster`] stand in for the raw [`v1alpha2::AirflowCluster`] when building owner
180- /// references and metadata for child objects. Kind/group/version are delegated to the CRD; the
181- /// `metadata` (name, namespace, uid) is captured during validation.
182- impl Resource for ValidatedCluster {
183- type DynamicType = <v1alpha2:: AirflowCluster as Resource >:: DynamicType ;
184- type Scope = <v1alpha2:: AirflowCluster as Resource >:: Scope ;
185-
186- fn kind ( dt : & Self :: DynamicType ) -> std:: borrow:: Cow < ' _ , str > {
187- v1alpha2:: AirflowCluster :: kind ( dt)
188- }
189-
190- fn group ( dt : & Self :: DynamicType ) -> std:: borrow:: Cow < ' _ , str > {
191- v1alpha2:: AirflowCluster :: group ( dt)
192- }
193-
194- fn version ( dt : & Self :: DynamicType ) -> std:: borrow:: Cow < ' _ , str > {
195- v1alpha2:: AirflowCluster :: version ( dt)
196- }
197-
198- fn plural ( dt : & Self :: DynamicType ) -> std:: borrow:: Cow < ' _ , str > {
199- v1alpha2:: AirflowCluster :: plural ( dt)
200- }
201-
202- fn meta ( & self ) -> & ObjectMeta {
203- & self . metadata
204- }
205-
206- fn meta_mut ( & mut self ) -> & mut ObjectMeta {
207- & mut self . metadata
208- }
209- }
210-
211110#[ derive( Snafu , Debug , EnumDiscriminants ) ]
212111#[ strum_discriminants( derive( IntoStaticStr ) ) ]
213112pub enum Error {
0 commit comments