Skip to content

Commit 3ee316b

Browse files
committed
missing v2::builder::meta::ownerreference_from_resource, clippy warnings
1 parent 458a463 commit 3ee316b

6 files changed

Lines changed: 26 additions & 26 deletions

File tree

rust/operator-binary/src/authentication/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use stackable_operator::crd::authentication;
1010
use crate::crd::authentication::{AuthenticationClassResolved, AuthenticationClassesResolved};
1111

1212
/// Type alias for Druid's OIDC client authentication options, opting in to the
13-
/// `clientAuthenticationMethod` field via [`oidc::v1alpha1::ClientAuthenticationMethodOption`].
13+
/// `clientAuthenticationMethod` field via
14+
/// [`authentication::oidc::v1alpha1::ClientAuthenticationMethodOption`].
1415
pub type DruidClientAuthenticationOptions =
1516
authentication::oidc::v1alpha1::ClientAuthenticationOptions<
1617
authentication::oidc::v1alpha1::ClientAuthenticationMethodOption,

rust/operator-binary/src/controller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub async fn reconcile_druid(
225225

226226
// The internal secret is shared across all roles and role groups, so it only needs to be
227227
// created once per reconcile rather than inside the role loop below.
228-
create_shared_internal_secret(druid, client, DRUID_CONTROLLER_NAME)
228+
create_shared_internal_secret(&validated_cluster, client, DRUID_CONTROLLER_NAME)
229229
.await
230230
.context(FailedInternalSecretCreationSnafu)?;
231231

rust/operator-binary/src/controller/build/resource/config_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
//! Metadata, owner reference and recommended labels are derived entirely from `ValidatedCluster`
99
//! (which carries the validated name/namespace/uid and implements `Resource`).
1010
//!
11-
//! The builder does not read the raw [`v1alpha1::DruidCluster`] at all: everything it needs is
12-
//! carried on `ValidatedCluster` (resolved during the validate step).
11+
//! The builder does not read the raw [`crate::crd::v1alpha1::DruidCluster`] at all: everything it
12+
//! needs is carried on `ValidatedCluster` (resolved during the validate step).
1313
1414
use std::collections::BTreeMap;
1515

rust/operator-binary/src/controller/dereference.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ pub struct DereferencedObjects {
7575
/// and its connection.
7676
pub s3_deep_storage_bucket: Option<s3::v1alpha1::ResolvedBucket>,
7777
/// The raw, fetched `AuthenticationClass` objects (in spec order). Validation of these happens
78-
/// in the validate step via [`AuthenticationClassesResolved::from_fetched`].
78+
/// in the validate step via
79+
/// [`crate::crd::authentication::AuthenticationClassesResolved::from_fetched`].
7980
pub authentication_classes: Vec<core::v1alpha1::AuthenticationClass>,
8081
}
8182

rust/operator-binary/src/controller/validate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ type Result<T, E = Error> = std::result::Result<T, E>;
8383
///
8484
/// This is the upstream [`stackable_operator::v2::role_utils::RoleGroupConfig`] (config plus the
8585
/// four merged override categories), with the typed per-role config erased to
86-
/// [`ValidatedDruidConfig`] so that all roles share a single type. The rendered per-file configs
87-
/// (runtime.properties / security.properties / jvm.config) are produced later, in the config-map
88-
/// build step.
86+
/// [`crate::crd::ValidatedDruidConfig`] so that all roles share a single type. The rendered
87+
/// per-file configs (runtime.properties / security.properties / jvm.config) are produced later, in
88+
/// the config-map build step.
8989
///
9090
/// Defined in [`crate::crd`] (where it has access to the private typed config fields) and
9191
/// re-exported here for the build step.

rust/operator-binary/src/internal_secret.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ use stackable_operator::{
66
client::Client,
77
k8s_openapi::api::core::v1::{EnvVar, EnvVarSource, Secret, SecretKeySelector},
88
kube::ResourceExt,
9+
v2::builder::meta::ownerreference_from_resource,
910
};
1011

11-
use crate::crd::{COOKIE_PASSPHRASE_ENV, security::INTERNAL_INITIAL_CLIENT_PASSWORD_ENV, v1alpha1};
12+
use crate::{
13+
controller::validate::ValidatedCluster,
14+
crd::{COOKIE_PASSPHRASE_ENV, security::INTERNAL_INITIAL_CLIENT_PASSWORD_ENV},
15+
};
1216

1317
#[derive(Snafu, Debug)]
1418
#[allow(clippy::enum_variant_names)]
@@ -30,19 +34,14 @@ pub enum Error {
3034

3135
#[snafu(display("object defines no namespace"))]
3236
ObjectHasNoNamespace,
33-
34-
#[snafu(display("object is missing metadata to build owner reference"))]
35-
ObjectMissingMetadataForOwnerRef {
36-
source: stackable_operator::builder::meta::Error,
37-
},
3837
}
3938

4039
pub async fn create_shared_internal_secret(
41-
druid: &v1alpha1::DruidCluster,
40+
cluster: &ValidatedCluster,
4241
client: &Client,
4342
controller_name: &str,
4443
) -> Result<(), Error> {
45-
let secret = build_shared_internal_secret(druid)?;
44+
let secret = build_shared_internal_secret(cluster);
4645
let existing_secret = client
4746
.get_opt::<Secret>(
4847
&secret.name_any(),
@@ -55,7 +54,7 @@ pub async fn create_shared_internal_secret(
5554
.context(FailedToRetrieveInternalSecretSnafu)?;
5655
let existing_immutable_secret = client
5756
.get_opt::<Secret>(
58-
&build_immutable_shared_internal_secret_name(druid),
57+
&build_immutable_shared_internal_secret_name(cluster),
5958
secret
6059
.namespace()
6160
.as_deref()
@@ -142,28 +141,27 @@ pub async fn create_shared_internal_secret(
142141
Ok(())
143142
}
144143

145-
fn build_shared_internal_secret(druid: &v1alpha1::DruidCluster) -> Result<Secret, Error> {
144+
fn build_shared_internal_secret(cluster: &ValidatedCluster) -> Secret {
146145
let mut internal_secret = BTreeMap::new();
147146
internal_secret.insert(
148147
INTERNAL_INITIAL_CLIENT_PASSWORD_ENV.to_string(),
149148
get_random_base64(),
150149
);
151150
internal_secret.insert(COOKIE_PASSPHRASE_ENV.to_string(), get_random_base64());
152151

153-
Ok(Secret {
152+
Secret {
154153
metadata: ObjectMetaBuilder::new()
155-
.name(build_shared_internal_secret_name(druid))
156-
.namespace_opt(druid.namespace())
157-
.ownerreference_from_resource(druid, None, Some(true))
158-
.context(ObjectMissingMetadataForOwnerRefSnafu)?
154+
.name(build_shared_internal_secret_name(cluster))
155+
.namespace_opt(cluster.namespace())
156+
.ownerreference(ownerreference_from_resource(cluster, None, Some(true)))
159157
.build(),
160158
string_data: Some(internal_secret),
161159
..Secret::default()
162-
})
160+
}
163161
}
164162

165-
fn build_immutable_shared_internal_secret_name(druid: &v1alpha1::DruidCluster) -> String {
166-
format!("{}-internal-secret", druid.name_any())
163+
fn build_immutable_shared_internal_secret_name(cluster: &ValidatedCluster) -> String {
164+
format!("{}-internal-secret", cluster.name_any())
167165
}
168166

169167
pub fn build_shared_internal_secret_name<T: ResourceExt>(owner: &T) -> String {

0 commit comments

Comments
 (0)