@@ -8,29 +8,18 @@ use std::{collections::BTreeMap, str::FromStr};
88use snafu:: { ResultExt , Snafu } ;
99use stackable_operator:: {
1010 cli:: OperatorEnvironmentOptions ,
11- commons:: product_image_selection:: { self , ResolvedProductImage } ,
12- kube:: { Resource , ResourceExt as _, api :: ObjectMeta } ,
11+ commons:: product_image_selection,
12+ kube:: ResourceExt as _,
1313 role_utils:: { GenericRoleConfig , JavaCommonConfig , JvmArgumentOverrides } ,
14- v2:: {
15- controller_utils:: { get_cluster_name, get_namespace, get_uid} ,
16- types:: {
17- kubernetes:: { NamespaceName , Uid } ,
18- operator:: ClusterName ,
19- } ,
20- } ,
14+ v2:: controller_utils:: { get_cluster_name, get_namespace, get_uid} ,
2115} ;
2216use strum:: { EnumDiscriminants , IntoEnumIterator , IntoStaticStr } ;
2317
18+ use super :: { ValidatedCluster , ValidatedClusterConfig , ValidatedTls } ;
2419use crate :: {
2520 authentication:: { self , TrinoAuthenticationConfig , TrinoAuthenticationTypes } ,
26- authorization:: opa:: TrinoOpaConfig ,
27- catalog:: config:: CatalogConfig ,
28- config:: {
29- client_protocol:: ResolvedClientProtocolConfig ,
30- fault_tolerant_execution:: ResolvedFaultTolerantExecutionConfig ,
31- } ,
3221 controller:: dereference:: DereferencedObjects ,
33- crd:: { TrinoRole , discovery :: TrinoPodRef , v1alpha1} ,
22+ crd:: { TrinoRole , v1alpha1} ,
3423 framework:: role_utils:: with_validated_config,
3524} ;
3625
@@ -98,107 +87,6 @@ pub type TrinoRoleGroupConfig = crate::framework::role_utils::RoleGroupConfig<
9887 v1alpha1:: TrinoConfigOverrides ,
9988> ;
10089
101- #[ derive( Clone , Debug ) ]
102- pub struct ValidatedTls {
103- pub server : Option < String > ,
104- pub internal : Option < String > ,
105- }
106-
107- /// Cluster-wide settings, grouped to parallel `spec.clusterConfig` CRD.
108- #[ derive( Clone , Debug ) ]
109- pub struct ValidatedClusterConfig {
110- pub tls : ValidatedTls ,
111- pub authentication : TrinoAuthenticationConfig ,
112- pub authentication_enabled : bool ,
113- pub authorization : Option < TrinoOpaConfig > ,
114- pub fault_tolerant_execution : Option < ResolvedFaultTolerantExecutionConfig > ,
115- pub client_protocol : Option < ResolvedClientProtocolConfig > ,
116- pub coordinator_pod_refs : Vec < TrinoPodRef > ,
117- pub catalogs : Vec < CatalogConfig > ,
118- }
119-
120- /// The validated TrinoCluster. The output of the validate step.
121- #[ derive( Clone , Debug ) ]
122- pub struct ValidatedCluster {
123- /// Metadata mirroring the source [`v1alpha1::TrinoCluster`] (name, namespace and UID).
124- ///
125- /// Kept private and only exposed through the [`Resource`] implementation, so that a
126- /// `ValidatedCluster` can be used directly as the owner of generated objects (e.g. to set
127- /// owner references) without threading the raw `TrinoCluster` through the build step.
128- metadata : ObjectMeta ,
129- pub name : ClusterName ,
130- pub namespace : NamespaceName ,
131- pub uid : Uid ,
132- pub image : ResolvedProductImage ,
133- pub product_version : u16 ,
134- pub cluster_config : ValidatedClusterConfig ,
135- pub role_group_configs : BTreeMap < TrinoRole , BTreeMap < RoleGroupName , TrinoRoleGroupConfig > > ,
136- /// Role-level JVM argument overrides per role. Required to render `jvm.config` in the build
137- /// step without access to the raw [`v1alpha1::TrinoCluster`] (the role-group level overrides
138- /// are carried by [`TrinoRoleGroupConfig::product_specific_common_config`]).
139- pub role_jvm_argument_overrides : BTreeMap < TrinoRole , JvmArgumentOverrides > ,
140- }
141-
142- impl ValidatedCluster {
143- #[ allow( clippy:: too_many_arguments) ]
144- pub fn new (
145- name : ClusterName ,
146- namespace : NamespaceName ,
147- uid : Uid ,
148- image : ResolvedProductImage ,
149- product_version : u16 ,
150- cluster_config : ValidatedClusterConfig ,
151- role_group_configs : BTreeMap < TrinoRole , BTreeMap < RoleGroupName , TrinoRoleGroupConfig > > ,
152- role_jvm_argument_overrides : BTreeMap < TrinoRole , JvmArgumentOverrides > ,
153- ) -> Self {
154- Self {
155- metadata : ObjectMeta {
156- name : Some ( name. to_string ( ) ) ,
157- namespace : Some ( namespace. to_string ( ) ) ,
158- uid : Some ( uid. to_string ( ) ) ,
159- ..ObjectMeta :: default ( )
160- } ,
161- name,
162- namespace,
163- uid,
164- image,
165- product_version,
166- cluster_config,
167- role_group_configs,
168- role_jvm_argument_overrides,
169- }
170- }
171- }
172-
173- impl Resource for ValidatedCluster {
174- type DynamicType = <v1alpha1:: TrinoCluster as Resource >:: DynamicType ;
175- type Scope = <v1alpha1:: TrinoCluster as Resource >:: Scope ;
176-
177- fn kind ( dt : & Self :: DynamicType ) -> std:: borrow:: Cow < ' _ , str > {
178- v1alpha1:: TrinoCluster :: kind ( dt)
179- }
180-
181- fn group ( dt : & Self :: DynamicType ) -> std:: borrow:: Cow < ' _ , str > {
182- v1alpha1:: TrinoCluster :: group ( dt)
183- }
184-
185- fn version ( dt : & Self :: DynamicType ) -> std:: borrow:: Cow < ' _ , str > {
186- v1alpha1:: TrinoCluster :: version ( dt)
187- }
188-
189- fn plural ( dt : & Self :: DynamicType ) -> std:: borrow:: Cow < ' _ , str > {
190- v1alpha1:: TrinoCluster :: plural ( dt)
191- }
192-
193- fn meta ( & self ) -> & ObjectMeta {
194- & self . metadata
195- }
196-
197- fn meta_mut ( & mut self ) -> & mut ObjectMeta {
198- & mut self . metadata
199- }
200- }
201-
20290/// Validates the cluster spec and dereferenced inputs.
20391pub fn validate (
20492 trino : & v1alpha1:: TrinoCluster ,
@@ -211,7 +99,7 @@ pub fn validate(
21199 . spec
212100 . image
213101 . resolve (
214- super :: CONTAINER_IMAGE_BASE_NAME ,
102+ crate :: trino_controller :: CONTAINER_IMAGE_BASE_NAME ,
215103 & operator_environment. image_repository ,
216104 crate :: built_info:: PKG_VERSION ,
217105 )
0 commit comments