From fed7fe578062bd5fadfc6d1788171cf528fc18f0 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Thu, 16 Nov 2023 10:27:26 +0100 Subject: [PATCH] Uopdate to new operator-rs version --- rust/operator-binary/Cargo.toml | 2 +- .../operator-binary/src/authentication/mod.rs | 16 ++++++++-------- .../src/authentication/oidc/mod.rs | 19 ++++++++++--------- .../src/authentication/password/file.rs | 9 ++++----- .../src/authentication/password/ldap.rs | 12 ++++++------ .../src/authentication/password/mod.rs | 11 +++++------ rust/operator-binary/src/catalog/commons.rs | 6 ++++-- 7 files changed, 38 insertions(+), 37 deletions(-) diff --git a/rust/operator-binary/Cargo.toml b/rust/operator-binary/Cargo.toml index 76c1751e..cb7b5389 100644 --- a/rust/operator-binary/Cargo.toml +++ b/rust/operator-binary/Cargo.toml @@ -19,10 +19,10 @@ futures.workspace = true indoc.workspace = true openssl.workspace = true pin-project.workspace = true +product-config.workspace = true semver.workspace = true snafu.workspace = true stackable-operator.workspace = true -product-config.workspace = true strum.workspace = true tokio.workspace = true tracing.workspace = true diff --git a/rust/operator-binary/src/authentication/mod.rs b/rust/operator-binary/src/authentication/mod.rs index eb3591e4..7af67054 100644 --- a/rust/operator-binary/src/authentication/mod.rs +++ b/rust/operator-binary/src/authentication/mod.rs @@ -542,12 +542,10 @@ impl TryFrom> for TrinoAuthenticationTypes { #[cfg(test)] mod tests { use super::*; + use stackable_operator::commons::authentication::static_; use stackable_operator::commons::secret_class::SecretClassVolume; use stackable_operator::{ - commons::authentication::{ - static_::UserCredentialsSecretRef, AuthenticationClassSpec, - StaticAuthenticationProvider, - }, + commons::authentication::{static_::UserCredentialsSecretRef, AuthenticationClassSpec}, kube::core::ObjectMeta, }; use stackable_trino_crd::RW_CONFIG_DIR_NAME; @@ -568,11 +566,13 @@ mod tests { ..ObjectMeta::default() }, spec: AuthenticationClassSpec { - provider: AuthenticationClassProvider::Static(StaticAuthenticationProvider { - user_credentials_secret: UserCredentialsSecretRef { - name: name.to_string(), + provider: AuthenticationClassProvider::Static( + static_::AuthenticationProvider { + user_credentials_secret: UserCredentialsSecretRef { + name: name.to_string(), + }, }, - }), + ), }, }, secret_ref: None, diff --git a/rust/operator-binary/src/authentication/oidc/mod.rs b/rust/operator-binary/src/authentication/oidc/mod.rs index a91f71bd..558123fa 100644 --- a/rust/operator-binary/src/authentication/oidc/mod.rs +++ b/rust/operator-binary/src/authentication/oidc/mod.rs @@ -4,9 +4,8 @@ use crate::authentication::TrinoAuthenticationConfig; use crate::command; use snafu::{OptionExt, ResultExt, Snafu}; -use stackable_operator::commons::authentication::{ - oidc::{CLIENT_ID_SECRET_KEY, CLIENT_SECRET_SECRET_KEY}, - OidcAuthenticationProvider, +use stackable_operator::commons::authentication::oidc::{ + self, CLIENT_ID_SECRET_KEY, CLIENT_SECRET_SECRET_KEY, }; use stackable_trino_crd::{TrinoRole, STACKABLE_CLIENT_TLS_DIR}; @@ -56,14 +55,14 @@ pub struct TrinoOidcAuthentication { #[derive(Clone, Debug)] pub struct OidcAuthenticator { name: String, - oidc: OidcAuthenticationProvider, + oidc: oidc::AuthenticationProvider, secret: Option, } impl OidcAuthenticator { pub fn new( name: String, - provider: OidcAuthenticationProvider, + provider: oidc::AuthenticationProvider, secret_ref: Option, ) -> Self { Self { @@ -113,12 +112,14 @@ impl TrinoOidcAuthentication { ); let (client_id_env, client_secret_env) = - OidcAuthenticationProvider::client_credentials_env_names(secret_name); + oidc::AuthenticationProvider::client_credentials_env_names(secret_name); oauth2_authentication_config.add_env_vars( TrinoRole::Coordinator, stackable_trino_crd::Container::Trino, - OidcAuthenticationProvider::client_credentials_env_var_mounts(secret_name.to_string()), + oidc::AuthenticationProvider::client_credentials_env_var_mounts( + secret_name.to_string(), + ), ); oauth2_authentication_config.add_config_property( @@ -217,7 +218,7 @@ mod tests { "# ); let deserializer = serde_yaml::Deserializer::from_str(&input); - let oidc_auth_provider: OidcAuthenticationProvider = + let oidc_auth_provider: oidc::AuthenticationProvider = serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap(); OidcAuthenticator::new( @@ -273,7 +274,7 @@ mod tests { ); assert_eq!( - Some(&format!("oauth2")), + Some(&"oauth2".to_string()), trino_oidc_auth .config_properties .get(&TrinoRole::Coordinator) diff --git a/rust/operator-binary/src/authentication/password/file.rs b/rust/operator-binary/src/authentication/password/file.rs index 021d8e55..018c5262 100644 --- a/rust/operator-binary/src/authentication/password/file.rs +++ b/rust/operator-binary/src/authentication/password/file.rs @@ -5,8 +5,7 @@ use stackable_operator::{ builder::{ resources::ResourceRequirementsBuilder, ContainerBuilder, VolumeBuilder, VolumeMountBuilder, }, - commons::authentication::StaticAuthenticationProvider, - commons::product_image_selection::ResolvedProductImage, + commons::{authentication::static_, product_image_selection::ResolvedProductImage}, k8s_openapi::api::core::v1::{Container, Volume, VolumeMount}, product_logging::{self, spec::AutomaticContainerLogConfig}, utils::COMMON_BASH_TRAP_FUNCTIONS, @@ -24,11 +23,11 @@ const FILE_PASSWORD_FILE: &str = "file.password-file"; #[derive(Clone, Debug)] pub struct FileAuthenticator { name: String, - file: StaticAuthenticationProvider, + file: static_::AuthenticationProvider, } impl FileAuthenticator { - pub fn new(name: String, provider: StaticAuthenticationProvider) -> Self { + pub fn new(name: String, provider: static_::AuthenticationProvider) -> Self { Self { name, file: provider, @@ -199,7 +198,7 @@ mod tests { fn test_file_authenticator() { let authenticator = FileAuthenticator::new( AUTH_CLASS_NAME.to_string(), - StaticAuthenticationProvider { + static_::AuthenticationProvider { user_credentials_secret: UserCredentialsSecretRef { name: "user_credentials".to_string(), }, diff --git a/rust/operator-binary/src/authentication/password/ldap.rs b/rust/operator-binary/src/authentication/password/ldap.rs index 7caa9507..76bf3e23 100644 --- a/rust/operator-binary/src/authentication/password/ldap.rs +++ b/rust/operator-binary/src/authentication/password/ldap.rs @@ -1,7 +1,7 @@ use crate::authentication::password; use snafu::Snafu; use stackable_operator::{ - commons::authentication::LdapAuthenticationProvider, + commons::authentication::ldap, k8s_openapi::api::core::v1::{Volume, VolumeMount}, }; use std::collections::BTreeMap; @@ -27,11 +27,11 @@ pub enum Error { #[derive(Clone, Debug)] pub struct LdapAuthenticator { name: String, - ldap: LdapAuthenticationProvider, + ldap: ldap::AuthenticationProvider, } impl LdapAuthenticator { - pub fn new(name: String, provider: LdapAuthenticationProvider) -> Self { + pub fn new(name: String, provider: ldap::AuthenticationProvider) -> Self { Self { name, ldap: provider, @@ -169,14 +169,14 @@ mod tests { bindCredentials: secretClass: test tls: - verification: + verification: server: - caCert: + caCert: secretClass: {TLS_SECRET_CLASS_NAME} "# ); let deserializer = serde_yaml::Deserializer::from_str(&input); - let ldap_auth_provider: LdapAuthenticationProvider = + let ldap_auth_provider: ldap::AuthenticationProvider = serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap(); LdapAuthenticator::new(AUTH_CLASS_NAME.to_string(), ldap_auth_provider) diff --git a/rust/operator-binary/src/authentication/password/mod.rs b/rust/operator-binary/src/authentication/password/mod.rs index e9e34ea6..61a0d11a 100644 --- a/rust/operator-binary/src/authentication/password/mod.rs +++ b/rust/operator-binary/src/authentication/password/mod.rs @@ -193,9 +193,8 @@ impl TrinoPasswordAuthentication { #[cfg(test)] mod tests { use super::*; - use serde_yaml; use stackable_operator::commons::authentication::{ - static_::UserCredentialsSecretRef, LdapAuthenticationProvider, StaticAuthenticationProvider, + ldap, static_, static_::UserCredentialsSecretRef, }; const FILE_AUTH_CLASS_1: &str = "file-auth-1"; @@ -203,7 +202,7 @@ mod tests { const LDAP_AUTH_CLASS_1: &str = "ldap-auth-1"; const LDAP_AUTH_CLASS_2: &str = "ldap-auth-2"; - fn ldap_provider() -> LdapAuthenticationProvider { + fn ldap_provider() -> ldap::AuthenticationProvider { let input = r#" hostname: my.ldap.server searchBase: ou=users,dc=example,dc=org @@ -216,7 +215,7 @@ mod tests { let authenticators = vec![ TrinoPasswordAuthenticator::File(FileAuthenticator::new( FILE_AUTH_CLASS_1.to_string(), - StaticAuthenticationProvider { + static_::AuthenticationProvider { user_credentials_secret: UserCredentialsSecretRef { name: FILE_AUTH_CLASS_1.to_string(), }, @@ -224,7 +223,7 @@ mod tests { )), TrinoPasswordAuthenticator::File(FileAuthenticator::new( FILE_AUTH_CLASS_2.to_string(), - StaticAuthenticationProvider { + static_::AuthenticationProvider { user_credentials_secret: UserCredentialsSecretRef { name: FILE_AUTH_CLASS_2.to_string(), }, @@ -272,7 +271,7 @@ mod tests { fn test_password_authentication_config_files() { let file_auth_1 = FileAuthenticator::new( FILE_AUTH_CLASS_1.to_string(), - StaticAuthenticationProvider { + static_::AuthenticationProvider { user_credentials_secret: UserCredentialsSecretRef { name: FILE_AUTH_CLASS_1.to_string(), }, diff --git a/rust/operator-binary/src/catalog/commons.rs b/rust/operator-binary/src/catalog/commons.rs index bc24a651..e4a91f12 100644 --- a/rust/operator-binary/src/catalog/commons.rs +++ b/rust/operator-binary/src/catalog/commons.rs @@ -2,11 +2,13 @@ use crate::command; use async_trait::async_trait; use snafu::{OptionExt, ResultExt}; -use stackable_operator::commons::authentication::{CaCert, TlsServerVerification, TlsVerification}; use stackable_operator::{ builder::{SecretOperatorVolumeSourceBuilder, VolumeBuilder, VolumeMountBuilder}, client::Client, - commons::s3::{S3AccessStyle, S3ConnectionDef}, + commons::{ + authentication::tls::{CaCert, TlsServerVerification, TlsVerification}, + s3::{S3AccessStyle, S3ConnectionDef}, + }, k8s_openapi::api::core::v1::ConfigMap, }; use stackable_trino_crd::catalog::commons::{HdfsConnection, MetastoreConnection};