Skip to content

Commit

Permalink
Uopdate to new operator-rs version
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Nov 16, 2023
1 parent 9034a37 commit fed7fe5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion rust/operator-binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions rust/operator-binary/src/authentication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,10 @@ impl TryFrom<Vec<ResolvedAuthenticationClassRef>> 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;
Expand All @@ -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,
Expand Down
19 changes: 10 additions & 9 deletions rust/operator-binary/src/authentication/oidc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -56,14 +55,14 @@ pub struct TrinoOidcAuthentication {
#[derive(Clone, Debug)]
pub struct OidcAuthenticator {
name: String,
oidc: OidcAuthenticationProvider,
oidc: oidc::AuthenticationProvider,
secret: Option<String>,
}

impl OidcAuthenticator {
pub fn new(
name: String,
provider: OidcAuthenticationProvider,
provider: oidc::AuthenticationProvider,
secret_ref: Option<String>,
) -> Self {
Self {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -273,7 +274,7 @@ mod tests {
);

assert_eq!(
Some(&format!("oauth2")),
Some(&"oauth2".to_string()),
trino_oidc_auth
.config_properties
.get(&TrinoRole::Coordinator)
Expand Down
9 changes: 4 additions & 5 deletions rust/operator-binary/src/authentication/password/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(),
},
Expand Down
12 changes: 6 additions & 6 deletions rust/operator-binary/src/authentication/password/ldap.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions rust/operator-binary/src/authentication/password/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,16 @@ 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";
const FILE_AUTH_CLASS_2: &str = "file-auth-2";
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
Expand All @@ -216,15 +215,15 @@ 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(),
},
},
)),
TrinoPasswordAuthenticator::File(FileAuthenticator::new(
FILE_AUTH_CLASS_2.to_string(),
StaticAuthenticationProvider {
static_::AuthenticationProvider {
user_credentials_secret: UserCredentialsSecretRef {
name: FILE_AUTH_CLASS_2.to_string(),
},
Expand Down Expand Up @@ -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(),
},
Expand Down
6 changes: 4 additions & 2 deletions rust/operator-binary/src/catalog/commons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit fed7fe5

Please sign in to comment.