@@ -22,16 +22,18 @@ use stackable_operator::{
22
22
k8s_openapi:: api:: core:: v1:: { Container , EnvVar , Volume , VolumeMount } ,
23
23
kube:: { runtime:: reflector:: ObjectRef , ResourceExt } ,
24
24
} ;
25
- use stackable_trino_crd:: { authentication:: ResolvedAuthenticationClassRef , TrinoRole } ;
26
25
use strum:: EnumDiscriminants ;
27
26
use tracing:: trace;
28
27
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
+ } ,
34
35
} ,
36
+ crd:: { authentication:: ResolvedAuthenticationClassRef , TrinoRole } ,
35
37
} ;
36
38
37
39
pub ( crate ) mod oidc;
@@ -85,14 +87,14 @@ pub struct TrinoAuthenticationConfig {
85
87
/// All extra config files required for authentication for each role.
86
88
config_files : HashMap < TrinoRole , BTreeMap < String , String > > ,
87
89
/// 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 > > > ,
89
91
/// 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 > > > ,
91
93
/// Additional volumes like secret mounts, user file database etc.
92
94
volumes : Vec < Volume > ,
93
95
/// Additional volume mounts for each role and container. Shared volumes have to be added
94
96
/// 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 > > > ,
96
98
/// Additional side car container for the provided role
97
99
sidecar_containers : HashMap < TrinoRole , Vec < Container > > ,
98
100
}
@@ -157,29 +159,27 @@ impl TrinoAuthenticationConfig {
157
159
. add_volumes ( self . volumes ( ) )
158
160
. context ( AddVolumeSnafu ) ?;
159
161
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 ] ;
164
164
165
165
for container in & affected_containers {
166
166
let volume_mounts = self . volume_mounts ( role, container) ;
167
167
168
168
match container {
169
- stackable_trino_crd :: Container :: Prepare => {
169
+ crate :: crd :: Container :: Prepare => {
170
170
prepare_builder
171
171
. add_volume_mounts ( volume_mounts)
172
172
. context ( AddVolumeMountSnafu ) ?;
173
173
}
174
- stackable_trino_crd :: Container :: Trino => {
174
+ crate :: crd :: Container :: Trino => {
175
175
trino_builder
176
176
. add_volume_mounts ( volume_mounts)
177
177
. context ( AddVolumeMountSnafu ) ?;
178
178
}
179
179
// handled internally
180
- stackable_trino_crd :: Container :: PasswordFileUpdater => { }
180
+ crate :: crd :: Container :: PasswordFileUpdater => { }
181
181
// nothing to do here
182
- stackable_trino_crd :: Container :: Vector => { }
182
+ crate :: crd :: Container :: Vector => { }
183
183
}
184
184
}
185
185
@@ -220,7 +220,7 @@ impl TrinoAuthenticationConfig {
220
220
pub fn add_env_vars (
221
221
& mut self ,
222
222
role : TrinoRole ,
223
- container : stackable_trino_crd :: Container ,
223
+ container : crate :: crd :: Container ,
224
224
env_var : Vec < EnvVar > ,
225
225
) {
226
226
self . env_vars
@@ -235,7 +235,7 @@ impl TrinoAuthenticationConfig {
235
235
pub fn add_commands (
236
236
& mut self ,
237
237
role : TrinoRole ,
238
- container : stackable_trino_crd :: Container ,
238
+ container : crate :: crd :: Container ,
239
239
commands : Vec < String > ,
240
240
) {
241
241
self . commands
@@ -265,7 +265,7 @@ impl TrinoAuthenticationConfig {
265
265
pub fn add_volume_mount (
266
266
& mut self ,
267
267
role : TrinoRole ,
268
- container : stackable_trino_crd :: Container ,
268
+ container : crate :: crd :: Container ,
269
269
volume_mount : VolumeMount ,
270
270
) {
271
271
let current_volume_mounts = self
@@ -288,7 +288,7 @@ impl TrinoAuthenticationConfig {
288
288
pub fn add_volume_mounts (
289
289
& mut self ,
290
290
role : TrinoRole ,
291
- container : stackable_trino_crd :: Container ,
291
+ container : crate :: crd :: Container ,
292
292
volume_mounts : Vec < VolumeMount > ,
293
293
) {
294
294
for volume_mount in volume_mounts {
@@ -319,11 +319,7 @@ impl TrinoAuthenticationConfig {
319
319
}
320
320
321
321
/// 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 > {
327
323
self . env_vars
328
324
. get ( role)
329
325
. cloned ( )
@@ -334,11 +330,7 @@ impl TrinoAuthenticationConfig {
334
330
}
335
331
336
332
/// 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 > {
342
334
self . commands
343
335
. get ( role)
344
336
. cloned ( )
@@ -357,7 +349,7 @@ impl TrinoAuthenticationConfig {
357
349
pub fn volume_mounts (
358
350
& self ,
359
351
role : & TrinoRole ,
360
- container : & stackable_trino_crd :: Container ,
352
+ container : & crate :: crd :: Container ,
361
353
) -> Vec < VolumeMount > {
362
354
if let Some ( volume_mounts) = self . volume_mounts . get ( role) {
363
355
volume_mounts. get ( container) . cloned ( ) . unwrap_or_default ( )
@@ -565,9 +557,9 @@ impl TryFrom<Vec<ResolvedAuthenticationClassRef>> for TrinoAuthenticationTypes {
565
557
#[ cfg( test) ]
566
558
mod tests {
567
559
use stackable_operator:: commons:: authentication:: oidc:: ClientAuthenticationOptions ;
568
- use stackable_trino_crd:: RW_CONFIG_DIR_NAME ;
569
560
570
561
use super :: * ;
562
+ use crate :: crd:: RW_CONFIG_DIR_NAME ;
571
563
572
564
const OIDC_AUTH_CLASS_1 : & str = "oidc-auth-1" ;
573
565
const FILE_AUTH_CLASS_1 : & str = "file-auth-1" ;
@@ -800,17 +792,15 @@ mod tests {
800
792
fn test_trino_password_authenticator_volume_mounts ( ) {
801
793
// nothing for workers
802
794
assert ! ( setup_authentication_config( )
803
- . volume_mounts( & TrinoRole :: Worker , & stackable_trino_crd :: Container :: Trino , )
795
+ . volume_mounts( & TrinoRole :: Worker , & crate :: crd :: Container :: Trino , )
804
796
. is_empty( ) ) ;
805
797
assert ! ( setup_authentication_config( )
806
- . volume_mounts( & TrinoRole :: Worker , & stackable_trino_crd :: Container :: Prepare , )
798
+ . volume_mounts( & TrinoRole :: Worker , & crate :: crd :: Container :: Prepare , )
807
799
. is_empty( ) ) ;
808
800
809
801
// 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 ) ;
814
804
815
805
// we expect one user password db mount
816
806
assert_eq ! ( coordinator_main_mounts. len( ) , 1 ) ;
@@ -828,30 +818,24 @@ mod tests {
828
818
829
819
// nothing for workers
830
820
assert ! ( auth_config
831
- . commands( & TrinoRole :: Worker , & stackable_trino_crd :: Container :: Trino )
821
+ . commands( & TrinoRole :: Worker , & crate :: crd :: Container :: Trino )
832
822
. is_empty( ) ) ;
833
823
assert ! ( auth_config_with_ldap_bind
834
- . commands( & TrinoRole :: Worker , & stackable_trino_crd :: Container :: Trino )
824
+ . commands( & TrinoRole :: Worker , & crate :: crd :: Container :: Trino )
835
825
. is_empty( ) ) ;
836
826
837
827
// we expect 0 entries because no bind credentials env export
838
828
assert_eq ! (
839
829
auth_config
840
- . commands(
841
- & TrinoRole :: Coordinator ,
842
- & stackable_trino_crd:: Container :: Trino
843
- )
830
+ . commands( & TrinoRole :: Coordinator , & crate :: crd:: Container :: Trino )
844
831
. len( ) ,
845
832
0
846
833
) ;
847
834
848
835
// We expect 8 entries because of "set +x", "set -x" and 2x user:password bind credential env export
849
836
assert_eq ! (
850
837
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 )
855
839
. len( ) ,
856
840
8
857
841
) ;
0 commit comments