From e9d201c289cda4c8287af5e536cf2892350cd11e Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Wed, 4 Dec 2024 17:47:39 +0100 Subject: [PATCH] chore: update references in the crates The versioned module is imported rather than the individual structs and enums (when there is no conflict, eg: if also importing a versioned shared struct) so that that usages show the version explicitly. There might be times where this isn't possible, for example, once structs and enums are versioned in stackable-operator, there could be multiple modules with the same name. In this case, user-info-fetcher is also versioned with v1alpha1, so it is referred to as user_info_fetcher::v1alpha1 in crd/mod.rs so as to not conflict with the crds v1alpha1. --- rust/operator-binary/src/controller.rs | 97 +++++++++++-------- rust/operator-binary/src/discovery.rs | 10 +- rust/operator-binary/src/main.rs | 10 +- .../src/operations/graceful_shutdown.rs | 4 +- rust/operator-binary/src/product_logging.rs | 10 +- .../user-info-fetcher/src/backend/keycloak.rs | 6 +- .../user-info-fetcher/src/backend/xfsc_aas.rs | 6 +- rust/user-info-fetcher/src/main.rs | 44 +++++---- 8 files changed, 104 insertions(+), 83 deletions(-) diff --git a/rust/operator-binary/src/controller.rs b/rust/operator-binary/src/controller.rs index 415f4965..8cd4fc56 100644 --- a/rust/operator-binary/src/controller.rs +++ b/rust/operator-binary/src/controller.rs @@ -10,8 +10,7 @@ use serde::{Deserialize, Serialize}; use serde_json::json; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_opa_operator::crd::{ - user_info_fetcher, Container, OpaCluster, OpaClusterStatus, OpaConfig, OpaRole, APP_NAME, - DEFAULT_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT, OPERATOR_NAME, + user_info_fetcher, v1alpha1, APP_NAME, DEFAULT_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT, OPERATOR_NAME, }; use stackable_operator::{ builder::{ @@ -175,31 +174,31 @@ pub enum Error { #[snafu(display("failed to apply Service for [{rolegroup}]"))] ApplyRoleGroupService { source: stackable_operator::cluster_resources::Error, - rolegroup: RoleGroupRef, + rolegroup: RoleGroupRef, }, #[snafu(display("failed to build ConfigMap for [{rolegroup}]"))] BuildRoleGroupConfig { source: stackable_operator::builder::configmap::Error, - rolegroup: RoleGroupRef, + rolegroup: RoleGroupRef, }, #[snafu(display("failed to apply ConfigMap for [{rolegroup}]"))] ApplyRoleGroupConfig { source: stackable_operator::cluster_resources::Error, - rolegroup: RoleGroupRef, + rolegroup: RoleGroupRef, }, #[snafu(display("failed to apply DaemonSet for [{rolegroup}]"))] ApplyRoleGroupDaemonSet { source: stackable_operator::cluster_resources::Error, - rolegroup: RoleGroupRef, + rolegroup: RoleGroupRef, }, #[snafu(display("failed to apply patch for DaemonSet for [{rolegroup}]"))] ApplyPatchRoleGroupDaemonSet { source: stackable_operator::client::Error, - rolegroup: RoleGroupRef, + rolegroup: RoleGroupRef, }, #[snafu(display("failed to patch service account"))] @@ -388,7 +387,7 @@ pub struct OpaClusterConfigDecisionLog { } pub async fn reconcile_opa( - opa: Arc>, + opa: Arc>, ctx: Arc, ) -> Result { tracing::info!("Starting reconcile"); @@ -404,7 +403,7 @@ pub async fn reconcile_opa( .spec .image .resolve(DOCKER_IMAGE_BASE_NAME, crate::built_info::PKG_VERSION); - let opa_role = OpaRole::Server; + let opa_role = v1alpha1::OpaRole::Server; let mut cluster_resources = ClusterResources::new( APP_NAME, @@ -563,7 +562,7 @@ pub async fn reconcile_opa( let cluster_operation_cond_builder = ClusterOperationsConditionBuilder::new(&opa.spec.cluster_operation); - let status = OpaClusterStatus { + let status = v1alpha1::OpaClusterStatus { conditions: compute_conditions(opa, &[&ds_cond_builder, &cluster_operation_cond_builder]), }; @@ -583,10 +582,10 @@ pub async fn reconcile_opa( /// The server-role service is the primary endpoint that should be used by clients that do not perform internal load balancing, /// including targets outside of the cluster. pub fn build_server_role_service( - opa: &OpaCluster, + opa: &v1alpha1::OpaCluster, resolved_product_image: &ResolvedProductImage, ) -> Result { - let role_name = OpaRole::Server.to_string(); + let role_name = v1alpha1::OpaRole::Server.to_string(); let role_svc_name = opa .server_role_service_name() .context(RoleServiceNameNotFoundSnafu)?; @@ -632,9 +631,9 @@ pub fn build_server_role_service( /// /// This is mostly useful for internal communication between peers, or for clients that perform client-side load balancing. fn build_rolegroup_service( - opa: &OpaCluster, + opa: &v1alpha1::OpaCluster, resolved_product_image: &ResolvedProductImage, - rolegroup: &RoleGroupRef, + rolegroup: &RoleGroupRef, ) -> Result { let prometheus_label = Label::try_from(("prometheus.io/scrape", "true")).context(BuildLabelSnafu)?; @@ -677,10 +676,10 @@ fn build_rolegroup_service( /// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the administrator fn build_server_rolegroup_config_map( - opa: &OpaCluster, + opa: &v1alpha1::OpaCluster, resolved_product_image: &ResolvedProductImage, - rolegroup: &RoleGroupRef, - merged_config: &OpaConfig, + rolegroup: &RoleGroupRef, + merged_config: &v1alpha1::OpaConfig, vector_aggregator_address: Option<&str>, ) -> Result { let mut cm_builder = ConfigMapBuilder::new(); @@ -736,12 +735,12 @@ fn build_server_rolegroup_config_map( /// policy queries (which are often chained in serial, and block other tasks in the products). #[allow(clippy::too_many_arguments)] fn build_server_rolegroup_daemonset( - opa: &OpaCluster, + opa: &v1alpha1::OpaCluster, resolved_product_image: &ResolvedProductImage, - opa_role: &OpaRole, - rolegroup_ref: &RoleGroupRef, + opa_role: &v1alpha1::OpaRole, + rolegroup_ref: &RoleGroupRef, server_config: &HashMap>, - merged_config: &OpaConfig, + merged_config: &v1alpha1::OpaConfig, opa_bundle_builder_image: &str, user_info_fetcher_image: &str, service_account: &ServiceAccount, @@ -764,15 +763,15 @@ fn build_server_rolegroup_daemonset( let mut pb = PodBuilder::new(); - let prepare_container_name = Container::Prepare.to_string(); + let prepare_container_name = v1alpha1::Container::Prepare.to_string(); let mut cb_prepare = ContainerBuilder::new(&prepare_container_name).context(IllegalContainerNameSnafu)?; - let bundle_builder_container_name = Container::BundleBuilder.to_string(); + let bundle_builder_container_name = v1alpha1::Container::BundleBuilder.to_string(); let mut cb_bundle_builder = ContainerBuilder::new(&bundle_builder_container_name).context(IllegalContainerNameSnafu)?; - let opa_container_name = Container::Opa.to_string(); + let opa_container_name = v1alpha1::Container::Opa.to_string(); let mut cb_opa = ContainerBuilder::new(&opa_container_name).context(IllegalContainerNameSnafu)?; @@ -967,9 +966,9 @@ fn build_server_rolegroup_daemonset( ); match &user_info.backend { - user_info_fetcher::Backend::None {} => {} - user_info_fetcher::Backend::ExperimentalXfscAas(_) => {} - user_info_fetcher::Backend::ActiveDirectory(ad) => { + user_info_fetcher::v1alpha1::Backend::None {} => {} + user_info_fetcher::v1alpha1::Backend::ExperimentalXfscAas(_) => {} + user_info_fetcher::v1alpha1::Backend::ActiveDirectory(ad) => { pb.add_volume( SecretClassVolume::new( ad.kerberos_secret_class_name.clone(), @@ -1003,7 +1002,7 @@ fn build_server_rolegroup_daemonset( .add_volumes_and_mounts(&mut pb, vec![&mut cb_user_info_fetcher]) .context(UserInfoFetcherTlsVolumeAndMountsSnafu)?; } - user_info_fetcher::Backend::Keycloak(keycloak) => { + user_info_fetcher::v1alpha1::Backend::Keycloak(keycloak) => { pb.add_volume( VolumeBuilder::new(USER_INFO_FETCHER_CREDENTIALS_VOLUME_NAME) .secret(SecretVolumeSource { @@ -1035,7 +1034,10 @@ fn build_server_rolegroup_daemonset( resolved_product_image, CONFIG_VOLUME_NAME, LOG_VOLUME_NAME, - merged_config.logging.containers.get(&Container::Vector), + merged_config + .logging + .containers + .get(&v1alpha1::Container::Vector), ResourceRequirementsBuilder::new() .with_cpu_request("250m") .with_cpu_limit("500m") @@ -1092,7 +1094,7 @@ fn build_server_rolegroup_daemonset( } pub fn error_policy( - _obj: Arc>, + _obj: Arc>, error: &Error, _ctx: Arc, ) -> Action { @@ -1104,12 +1106,15 @@ pub fn error_policy( } } -fn build_config_file(merged_config: &OpaConfig) -> String { +fn build_config_file(merged_config: &v1alpha1::OpaConfig) -> String { let mut decision_logging_enabled = DEFAULT_DECISION_LOGGING_ENABLED; if let Some(ContainerLogConfig { choice: Some(ContainerLogConfigChoice::Automatic(log_config)), - }) = merged_config.logging.containers.get(&Container::Opa) + }) = merged_config + .logging + .containers + .get(&v1alpha1::Container::Opa) { if let Some(config) = log_config.loggers.get("decision") { decision_logging_enabled = config.level != LogLevel::NONE; @@ -1129,7 +1134,7 @@ fn build_config_file(merged_config: &OpaConfig) -> String { serde_json::to_string_pretty(&json!(config)).unwrap() } -fn build_opa_start_command(merged_config: &OpaConfig, container_name: &str) -> String { +fn build_opa_start_command(merged_config: &v1alpha1::OpaConfig, container_name: &str) -> String { let mut file_log_level = DEFAULT_FILE_LOG_LEVEL; let mut console_log_level = DEFAULT_CONSOLE_LOG_LEVEL; let mut server_log_level = DEFAULT_SERVER_LOG_LEVEL; @@ -1137,7 +1142,10 @@ fn build_opa_start_command(merged_config: &OpaConfig, container_name: &str) -> S if let Some(ContainerLogConfig { choice: Some(ContainerLogConfigChoice::Automatic(log_config)), - }) = merged_config.logging.containers.get(&Container::Opa) + }) = merged_config + .logging + .containers + .get(&v1alpha1::Container::Opa) { if let Some(AppenderConfig { level: Some(log_level), @@ -1198,7 +1206,10 @@ fn build_opa_start_command(merged_config: &OpaConfig, container_name: &str) -> S } } -fn build_bundle_builder_start_command(merged_config: &OpaConfig, container_name: &str) -> String { +fn build_bundle_builder_start_command( + merged_config: &v1alpha1::OpaConfig, + container_name: &str, +) -> String { let mut console_logging_off = false; // We need to check if the console logging is deactivated (NONE) @@ -1208,7 +1219,7 @@ fn build_bundle_builder_start_command(merged_config: &OpaConfig, container_name: }) = merged_config .logging .containers - .get(&Container::BundleBuilder) + .get(&v1alpha1::Container::BundleBuilder) { if let Some(AppenderConfig { level: Some(log_level), @@ -1233,13 +1244,13 @@ fn build_bundle_builder_start_command(merged_config: &OpaConfig, container_name: } } -fn bundle_builder_log_level(merged_config: &OpaConfig) -> BundleBuilderLogLevel { +fn bundle_builder_log_level(merged_config: &v1alpha1::OpaConfig) -> BundleBuilderLogLevel { if let Some(ContainerLogConfig { choice: Some(ContainerLogConfigChoice::Automatic(log_config)), }) = merged_config .logging .containers - .get(&Container::BundleBuilder) + .get(&v1alpha1::Container::BundleBuilder) { if let Some(logger) = log_config .loggers @@ -1252,11 +1263,17 @@ fn bundle_builder_log_level(merged_config: &OpaConfig) -> BundleBuilderLogLevel BundleBuilderLogLevel::Info } -fn build_prepare_start_command(merged_config: &OpaConfig, container_name: &str) -> Vec { +fn build_prepare_start_command( + merged_config: &v1alpha1::OpaConfig, + container_name: &str, +) -> Vec { let mut prepare_container_args = vec![]; if let Some(ContainerLogConfig { choice: Some(ContainerLogConfigChoice::Automatic(log_config)), - }) = merged_config.logging.containers.get(&Container::Prepare) + }) = merged_config + .logging + .containers + .get(&v1alpha1::Container::Prepare) { prepare_container_args.push(product_logging::framework::capture_shell_output( STACKABLE_LOG_DIR, diff --git a/rust/operator-binary/src/discovery.rs b/rust/operator-binary/src/discovery.rs index 4095a706..6b88357f 100644 --- a/rust/operator-binary/src/discovery.rs +++ b/rust/operator-binary/src/discovery.rs @@ -1,7 +1,7 @@ use crate::controller::{build_recommended_labels, APP_PORT}; use snafu::{OptionExt, ResultExt, Snafu}; -use stackable_opa_operator::crd::{OpaCluster, OpaRole}; +use stackable_opa_operator::crd::v1alpha1; use stackable_operator::{ builder::{configmap::ConfigMapBuilder, meta::ObjectMetaBuilder}, commons::product_image_selection::ResolvedProductImage, @@ -15,7 +15,7 @@ pub enum Error { #[snafu(display("object {} is missing metadata to build owner reference", opa))] ObjectMissingMetadataForOwnerRef { source: stackable_operator::builder::meta::Error, - opa: ObjectRef, + opa: ObjectRef, }, #[snafu(display("object has no name associated"))] @@ -38,7 +38,7 @@ pub enum Error { /// Builds discovery [`ConfigMap`]s for connecting to a [`OpaCluster`] for all expected scenarios pub fn build_discovery_configmaps( owner: &impl Resource, - opa: &OpaCluster, + opa: &v1alpha1::OpaCluster, resolved_product_image: &ResolvedProductImage, svc: &Service, cluster_info: &KubernetesClusterInfo, @@ -58,7 +58,7 @@ pub fn build_discovery_configmaps( fn build_discovery_configmap( name: &str, owner: &impl Resource, - opa: &OpaCluster, + opa: &v1alpha1::OpaCluster, resolved_product_image: &ResolvedProductImage, svc: &Service, cluster_info: &KubernetesClusterInfo, @@ -85,7 +85,7 @@ fn build_discovery_configmap( .with_recommended_labels(build_recommended_labels( opa, &resolved_product_image.app_version_label, - &OpaRole::Server.to_string(), + &v1alpha1::OpaRole::Server.to_string(), "discovery", )) .context(ObjectMetaSnafu)? diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index 67aece83..ccc34bb8 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use clap::{crate_description, crate_version, Parser}; use futures::StreamExt; use product_config::ProductConfigManager; -use stackable_opa_operator::crd::{OpaCluster, APP_NAME, OPERATOR_NAME}; +use stackable_opa_operator::crd::{v1alpha1, OpaCluster, APP_NAME, OPERATOR_NAME}; use stackable_operator::{ cli::{Command, ProductOperatorRun}, client::{self, Client}, @@ -18,7 +18,8 @@ use stackable_operator::{ }, logging::controller::report_controller_reconciled, namespace::WatchNamespace, - CustomResourceExt, + shared::yaml::SerializeOptions, + YamlSchema, }; use crate::controller::OPA_CONTROLLER_NAME; @@ -54,7 +55,8 @@ async fn main() -> anyhow::Result<()> { let opts = Opts::parse(); match opts.cmd { Command::Crd => { - OpaCluster::print_yaml_schema(built_info::PKG_VERSION)?; + OpaCluster::merged_crd(OpaCluster::V1Alpha1)? + .print_yaml_schema(built_info::PKG_VERSION, SerializeOptions::default())?; } Command::Run(OpaRun { operator_image, @@ -112,7 +114,7 @@ async fn create_controller( opa_bundle_builder_image: String, user_info_fetcher_image: String, ) { - let opa_api: Api> = watch_namespace.get_api(&client); + let opa_api: Api> = watch_namespace.get_api(&client); let daemonsets_api: Api> = watch_namespace.get_api(&client); let configmaps_api: Api> = watch_namespace.get_api(&client); let services_api: Api> = watch_namespace.get_api(&client); diff --git a/rust/operator-binary/src/operations/graceful_shutdown.rs b/rust/operator-binary/src/operations/graceful_shutdown.rs index 9ae46ac0..cd0f9805 100644 --- a/rust/operator-binary/src/operations/graceful_shutdown.rs +++ b/rust/operator-binary/src/operations/graceful_shutdown.rs @@ -1,5 +1,5 @@ use snafu::{ResultExt, Snafu}; -use stackable_opa_operator::crd::{OpaConfig, SERVER_GRACEFUL_SHUTDOWN_SAFETY_OVERHEAD}; +use stackable_opa_operator::crd::{v1alpha1, SERVER_GRACEFUL_SHUTDOWN_SAFETY_OVERHEAD}; use stackable_operator::builder::pod::PodBuilder; #[derive(Debug, Snafu)] @@ -11,7 +11,7 @@ pub enum Error { } pub fn add_graceful_shutdown_config( - merged_config: &OpaConfig, + merged_config: &v1alpha1::OpaConfig, pod_builder: &mut PodBuilder, ) -> Result<(), Error> { // This must be always set by the merge mechanism, as we provide a default value, diff --git a/rust/operator-binary/src/product_logging.rs b/rust/operator-binary/src/product_logging.rs index 30ca66f6..89d7a3ca 100644 --- a/rust/operator-binary/src/product_logging.rs +++ b/rust/operator-binary/src/product_logging.rs @@ -1,5 +1,5 @@ use snafu::{OptionExt, ResultExt, Snafu}; -use stackable_opa_operator::crd::{Container, OpaCluster}; +use stackable_opa_operator::crd::v1alpha1; use stackable_operator::product_logging::spec::LogLevel; use stackable_operator::{ builder::configmap::ConfigMapBuilder, @@ -78,7 +78,7 @@ impl From for BundleBuilderLogLevel { /// Return the address of the Vector aggregator if the corresponding ConfigMap name is given in the /// cluster spec pub async fn resolve_vector_aggregator_address( - opa: &OpaCluster, + opa: &v1alpha1::OpaCluster, client: &Client, ) -> Result> { let vector_aggregator_address = if let Some(vector_aggregator_config_map_name) = @@ -111,14 +111,14 @@ pub async fn resolve_vector_aggregator_address( /// Extend the role group ConfigMap with logging and Vector configurations pub fn extend_role_group_config_map( - rolegroup: &RoleGroupRef, + rolegroup: &RoleGroupRef, vector_aggregator_address: Option<&str>, - logging: &Logging, + logging: &Logging, cm_builder: &mut ConfigMapBuilder, ) -> Result<()> { let vector_log_config = if let Some(ContainerLogConfig { choice: Some(ContainerLogConfigChoice::Automatic(log_config)), - }) = logging.containers.get(&Container::Vector) + }) = logging.containers.get(&v1alpha1::Container::Vector) { Some(log_config) } else { diff --git a/rust/user-info-fetcher/src/backend/keycloak.rs b/rust/user-info-fetcher/src/backend/keycloak.rs index dfc88b64..85f61ec1 100644 --- a/rust/user-info-fetcher/src/backend/keycloak.rs +++ b/rust/user-info-fetcher/src/backend/keycloak.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use hyper::StatusCode; use serde::Deserialize; use snafu::{OptionExt, ResultExt, Snafu}; -use stackable_opa_operator::crd::user_info_fetcher as crd; +use stackable_opa_operator::crd::user_info_fetcher::v1alpha1; use stackable_operator::commons::authentication::oidc; use crate::{http_error, utils::http::send_json_request, Credentials, UserInfo, UserInfoRequest}; @@ -90,9 +90,9 @@ pub(crate) async fn get_user_info( req: &UserInfoRequest, http: &reqwest::Client, credentials: &Credentials, - config: &crd::KeycloakBackend, + config: &v1alpha1::KeycloakBackend, ) -> Result { - let crd::KeycloakBackend { + let v1alpha1::KeycloakBackend { client_credentials_secret: _, admin_realm, user_realm, diff --git a/rust/user-info-fetcher/src/backend/xfsc_aas.rs b/rust/user-info-fetcher/src/backend/xfsc_aas.rs index 51f6b41b..693cdfe9 100644 --- a/rust/user-info-fetcher/src/backend/xfsc_aas.rs +++ b/rust/user-info-fetcher/src/backend/xfsc_aas.rs @@ -15,7 +15,7 @@ use std::collections::HashMap; use hyper::StatusCode; use serde::Deserialize; use snafu::{ResultExt, Snafu}; -use stackable_opa_operator::crd::user_info_fetcher as crd; +use stackable_opa_operator::crd::user_info_fetcher::v1alpha1; use url::Url; use crate::{http_error, utils::http::send_json_request, UserInfo, UserInfoRequest}; @@ -81,9 +81,9 @@ impl TryFrom for UserInfo { pub(crate) async fn get_user_info( req: &UserInfoRequest, http: &reqwest::Client, - config: &crd::AasBackend, + config: &v1alpha1::AasBackend, ) -> Result { - let crd::AasBackend { hostname, port } = config; + let v1alpha1::AasBackend { hostname, port } = config; let cip_endpoint_raw = format!("http://{hostname}:{port}{API_PATH}"); let cip_endpoint = Url::parse(&cip_endpoint_raw).context(ParseAasEndpointUrlSnafu { diff --git a/rust/user-info-fetcher/src/main.rs b/rust/user-info-fetcher/src/main.rs index f627d7ca..5372ac4c 100644 --- a/rust/user-info-fetcher/src/main.rs +++ b/rust/user-info-fetcher/src/main.rs @@ -12,7 +12,7 @@ use moka::future::Cache; use reqwest::ClientBuilder; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; -use stackable_opa_operator::crd::user_info_fetcher as crd; +use stackable_opa_operator::crd::user_info_fetcher::v1alpha1; use tokio::net::TcpListener; mod backend; @@ -33,7 +33,7 @@ pub struct Args { #[derive(Clone)] struct AppState { - config: Arc, + config: Arc, http: reqwest::Client, credentials: Arc, user_info_cache: Cache, @@ -100,24 +100,24 @@ async fn main() -> Result<(), StartupError> { } }; - let config = Arc::::new( + let config = Arc::::new( serde_json::from_str(&read_config_file(&args.config).await?).context(ParseConfigSnafu)?, ); let credentials = Arc::new(match &config.backend { // TODO: factor this out into each backend (e.g. when we add LDAP support) - crd::Backend::None {} => Credentials { + v1alpha1::Backend::None {} => Credentials { client_id: "".to_string(), client_secret: "".to_string(), }, - crd::Backend::Keycloak(_) => Credentials { + v1alpha1::Backend::Keycloak(_) => Credentials { client_id: read_config_file(&args.credentials_dir.join("clientId")).await?, client_secret: read_config_file(&args.credentials_dir.join("clientSecret")).await?, }, - crd::Backend::ExperimentalXfscAas(_) => Credentials { + v1alpha1::Backend::ExperimentalXfscAas(_) => Credentials { client_id: "".to_string(), client_secret: "".to_string(), }, - crd::Backend::ActiveDirectory(_) => Credentials { + v1alpha1::Backend::ActiveDirectory(_) => Credentials { client_id: "".to_string(), client_secret: "".to_string(), }, @@ -129,7 +129,7 @@ async fn main() -> Result<(), StartupError> { // We could factor it out in the provider specific implementation (e.g. when we add LDAP support). // I know it is for setting up the client, but an idea: make a trait for implementing backends // The trait can do all this for a genric client using an implementation on the trait (eg: get_http_client() which will call self.uses_tls()) - if let crd::Backend::Keycloak(keycloak) = &config.backend { + if let v1alpha1::Backend::Keycloak(keycloak) = &config.backend { client_builder = utils::tls::configure_reqwest(&keycloak.tls, client_builder) .await .context(ConfigureTlsSnafu)?; @@ -137,7 +137,7 @@ async fn main() -> Result<(), StartupError> { let http = client_builder.build().context(ConstructHttpClientSnafu)?; let user_info_cache = { - let crd::Cache { entry_time_to_live } = config.cache; + let v1alpha1::Cache { entry_time_to_live } = config.cache; Cache::builder() .name("user-info") .time_to_live(*entry_time_to_live) @@ -262,7 +262,7 @@ async fn get_user_info( user_info_cache .try_get_with_by_ref(&req, async { match &config.backend { - crd::Backend::None {} => { + v1alpha1::Backend::None {} => { let user_id = match &req { UserInfoRequest::UserInfoRequestById(UserInfoRequestById { id }) => { Some(id) @@ -282,25 +282,27 @@ async fn get_user_info( custom_attributes: HashMap::new(), }) } - crd::Backend::Keycloak(keycloak) => { + v1alpha1::Backend::Keycloak(keycloak) => { backend::keycloak::get_user_info(&req, &http, &credentials, keycloak) .await .context(get_user_info_error::KeycloakSnafu) } - crd::Backend::ExperimentalXfscAas(aas) => { + v1alpha1::Backend::ExperimentalXfscAas(aas) => { backend::xfsc_aas::get_user_info(&req, &http, aas) .await .context(get_user_info_error::ExperimentalXfscAasSnafu) } - crd::Backend::ActiveDirectory(ad) => backend::active_directory::get_user_info( - &req, - &ad.ldap_server, - &ad.tls, - &ad.base_distinguished_name, - &ad.custom_attribute_mappings, - ) - .await - .context(get_user_info_error::ActiveDirectorySnafu), + v1alpha1::Backend::ActiveDirectory(ad) => { + backend::active_directory::get_user_info( + &req, + &ad.ldap_server, + &ad.tls, + &ad.base_distinguished_name, + &ad.custom_attribute_mappings, + ) + .await + .context(get_user_info_error::ActiveDirectorySnafu) + } } }) .await?,