@@ -22,16 +22,18 @@ use stackable_operator::{
2222 k8s_openapi:: api:: core:: v1:: { Container , EnvVar , Volume , VolumeMount } ,
2323 kube:: { runtime:: reflector:: ObjectRef , ResourceExt } ,
2424} ;
25- use stackable_trino_crd:: { authentication:: ResolvedAuthenticationClassRef , TrinoRole } ;
2625use strum:: EnumDiscriminants ;
2726use tracing:: trace;
2827
29- use crate :: authentication:: {
30- oidc:: { OidcAuthenticator , TrinoOidcAuthentication } ,
31- password:: {
32- file:: FileAuthenticator , ldap:: LdapAuthenticator , TrinoPasswordAuthentication ,
33- TrinoPasswordAuthenticator ,
28+ use crate :: {
29+ authentication:: {
30+ oidc:: { OidcAuthenticator , TrinoOidcAuthentication } ,
31+ password:: {
32+ file:: FileAuthenticator , ldap:: LdapAuthenticator , TrinoPasswordAuthentication ,
33+ TrinoPasswordAuthenticator ,
34+ } ,
3435 } ,
36+ crd:: { authentication:: ResolvedAuthenticationClassRef , TrinoRole } ,
3537} ;
3638
3739pub ( crate ) mod oidc;
@@ -85,14 +87,14 @@ pub struct TrinoAuthenticationConfig {
8587 /// All extra config files required for authentication for each role.
8688 config_files : HashMap < TrinoRole , BTreeMap < String , String > > ,
8789 /// Additional env variables for a certain role and container
88- env_vars : HashMap < TrinoRole , BTreeMap < stackable_trino_crd :: Container , Vec < EnvVar > > > ,
90+ env_vars : HashMap < TrinoRole , BTreeMap < crate :: crd :: Container , Vec < EnvVar > > > ,
8991 /// All extra container commands for a certain role and container
90- commands : HashMap < TrinoRole , BTreeMap < stackable_trino_crd :: Container , Vec < String > > > ,
92+ commands : HashMap < TrinoRole , BTreeMap < crate :: crd :: Container , Vec < String > > > ,
9193 /// Additional volumes like secret mounts, user file database etc.
9294 volumes : Vec < Volume > ,
9395 /// Additional volume mounts for each role and container. Shared volumes have to be added
9496 /// manually in each container.
95- volume_mounts : HashMap < TrinoRole , BTreeMap < stackable_trino_crd :: Container , Vec < VolumeMount > > > ,
97+ volume_mounts : HashMap < TrinoRole , BTreeMap < crate :: crd :: Container , Vec < VolumeMount > > > ,
9698 /// Additional side car container for the provided role
9799 sidecar_containers : HashMap < TrinoRole , Vec < Container > > ,
98100}
@@ -157,29 +159,27 @@ impl TrinoAuthenticationConfig {
157159 . add_volumes ( self . volumes ( ) )
158160 . context ( AddVolumeSnafu ) ?;
159161
160- let affected_containers = vec ! [
161- stackable_trino_crd:: Container :: Prepare ,
162- stackable_trino_crd:: Container :: Trino ,
163- ] ;
162+ let affected_containers =
163+ vec ! [ crate :: crd:: Container :: Prepare , crate :: crd:: Container :: Trino ] ;
164164
165165 for container in & affected_containers {
166166 let volume_mounts = self . volume_mounts ( role, container) ;
167167
168168 match container {
169- stackable_trino_crd :: Container :: Prepare => {
169+ crate :: crd :: Container :: Prepare => {
170170 prepare_builder
171171 . add_volume_mounts ( volume_mounts)
172172 . context ( AddVolumeMountSnafu ) ?;
173173 }
174- stackable_trino_crd :: Container :: Trino => {
174+ crate :: crd :: Container :: Trino => {
175175 trino_builder
176176 . add_volume_mounts ( volume_mounts)
177177 . context ( AddVolumeMountSnafu ) ?;
178178 }
179179 // handled internally
180- stackable_trino_crd :: Container :: PasswordFileUpdater => { }
180+ crate :: crd :: Container :: PasswordFileUpdater => { }
181181 // nothing to do here
182- stackable_trino_crd :: Container :: Vector => { }
182+ crate :: crd :: Container :: Vector => { }
183183 }
184184 }
185185
@@ -220,7 +220,7 @@ impl TrinoAuthenticationConfig {
220220 pub fn add_env_vars (
221221 & mut self ,
222222 role : TrinoRole ,
223- container : stackable_trino_crd :: Container ,
223+ container : crate :: crd :: Container ,
224224 env_var : Vec < EnvVar > ,
225225 ) {
226226 self . env_vars
@@ -235,7 +235,7 @@ impl TrinoAuthenticationConfig {
235235 pub fn add_commands (
236236 & mut self ,
237237 role : TrinoRole ,
238- container : stackable_trino_crd :: Container ,
238+ container : crate :: crd :: Container ,
239239 commands : Vec < String > ,
240240 ) {
241241 self . commands
@@ -265,7 +265,7 @@ impl TrinoAuthenticationConfig {
265265 pub fn add_volume_mount (
266266 & mut self ,
267267 role : TrinoRole ,
268- container : stackable_trino_crd :: Container ,
268+ container : crate :: crd :: Container ,
269269 volume_mount : VolumeMount ,
270270 ) {
271271 let current_volume_mounts = self
@@ -288,7 +288,7 @@ impl TrinoAuthenticationConfig {
288288 pub fn add_volume_mounts (
289289 & mut self ,
290290 role : TrinoRole ,
291- container : stackable_trino_crd :: Container ,
291+ container : crate :: crd :: Container ,
292292 volume_mounts : Vec < VolumeMount > ,
293293 ) {
294294 for volume_mount in volume_mounts {
@@ -319,11 +319,7 @@ impl TrinoAuthenticationConfig {
319319 }
320320
321321 /// Retrieve additional env vars for a given role and container.
322- pub fn env_vars (
323- & self ,
324- role : & TrinoRole ,
325- container : & stackable_trino_crd:: Container ,
326- ) -> Vec < EnvVar > {
322+ pub fn env_vars ( & self , role : & TrinoRole , container : & crate :: crd:: Container ) -> Vec < EnvVar > {
327323 self . env_vars
328324 . get ( role)
329325 . cloned ( )
@@ -334,11 +330,7 @@ impl TrinoAuthenticationConfig {
334330 }
335331
336332 /// Retrieve additional container commands for a given role and container.
337- pub fn commands (
338- & self ,
339- role : & TrinoRole ,
340- container : & stackable_trino_crd:: Container ,
341- ) -> Vec < String > {
333+ pub fn commands ( & self , role : & TrinoRole , container : & crate :: crd:: Container ) -> Vec < String > {
342334 self . commands
343335 . get ( role)
344336 . cloned ( )
@@ -357,7 +349,7 @@ impl TrinoAuthenticationConfig {
357349 pub fn volume_mounts (
358350 & self ,
359351 role : & TrinoRole ,
360- container : & stackable_trino_crd :: Container ,
352+ container : & crate :: crd :: Container ,
361353 ) -> Vec < VolumeMount > {
362354 if let Some ( volume_mounts) = self . volume_mounts . get ( role) {
363355 volume_mounts. get ( container) . cloned ( ) . unwrap_or_default ( )
@@ -565,9 +557,9 @@ impl TryFrom<Vec<ResolvedAuthenticationClassRef>> for TrinoAuthenticationTypes {
565557#[ cfg( test) ]
566558mod tests {
567559 use stackable_operator:: commons:: authentication:: oidc:: ClientAuthenticationOptions ;
568- use stackable_trino_crd:: RW_CONFIG_DIR_NAME ;
569560
570561 use super :: * ;
562+ use crate :: crd:: RW_CONFIG_DIR_NAME ;
571563
572564 const OIDC_AUTH_CLASS_1 : & str = "oidc-auth-1" ;
573565 const FILE_AUTH_CLASS_1 : & str = "file-auth-1" ;
@@ -800,17 +792,15 @@ mod tests {
800792 fn test_trino_password_authenticator_volume_mounts ( ) {
801793 // nothing for workers
802794 assert ! ( setup_authentication_config( )
803- . volume_mounts( & TrinoRole :: Worker , & stackable_trino_crd :: Container :: Trino , )
795+ . volume_mounts( & TrinoRole :: Worker , & crate :: crd :: Container :: Trino , )
804796 . is_empty( ) ) ;
805797 assert ! ( setup_authentication_config( )
806- . volume_mounts( & TrinoRole :: Worker , & stackable_trino_crd :: Container :: Prepare , )
798+ . volume_mounts( & TrinoRole :: Worker , & crate :: crd :: Container :: Prepare , )
807799 . is_empty( ) ) ;
808800
809801 // coordinator - main container
810- let coordinator_main_mounts = setup_authentication_config ( ) . volume_mounts (
811- & TrinoRole :: Coordinator ,
812- & stackable_trino_crd:: Container :: Trino ,
813- ) ;
802+ let coordinator_main_mounts = setup_authentication_config ( )
803+ . volume_mounts ( & TrinoRole :: Coordinator , & crate :: crd:: Container :: Trino ) ;
814804
815805 // we expect one user password db mount
816806 assert_eq ! ( coordinator_main_mounts. len( ) , 1 ) ;
@@ -828,30 +818,24 @@ mod tests {
828818
829819 // nothing for workers
830820 assert ! ( auth_config
831- . commands( & TrinoRole :: Worker , & stackable_trino_crd :: Container :: Trino )
821+ . commands( & TrinoRole :: Worker , & crate :: crd :: Container :: Trino )
832822 . is_empty( ) ) ;
833823 assert ! ( auth_config_with_ldap_bind
834- . commands( & TrinoRole :: Worker , & stackable_trino_crd :: Container :: Trino )
824+ . commands( & TrinoRole :: Worker , & crate :: crd :: Container :: Trino )
835825 . is_empty( ) ) ;
836826
837827 // we expect 0 entries because no bind credentials env export
838828 assert_eq ! (
839829 auth_config
840- . commands(
841- & TrinoRole :: Coordinator ,
842- & stackable_trino_crd:: Container :: Trino
843- )
830+ . commands( & TrinoRole :: Coordinator , & crate :: crd:: Container :: Trino )
844831 . len( ) ,
845832 0
846833 ) ;
847834
848835 // We expect 8 entries because of "set +x", "set -x" and 2x user:password bind credential env export
849836 assert_eq ! (
850837 auth_config_with_ldap_bind
851- . commands(
852- & TrinoRole :: Coordinator ,
853- & stackable_trino_crd:: Container :: Trino
854- )
838+ . commands( & TrinoRole :: Coordinator , & crate :: crd:: Container :: Trino )
855839 . len( ) ,
856840 8
857841 ) ;
0 commit comments