Skip to content

Commit bb3f331

Browse files
committed
feat: Add v1alpha2, rename experimentalGenerateSamAccountName
1 parent 781bdb5 commit bb3f331

File tree

12 files changed

+355
-206
lines changed

12 files changed

+355
-206
lines changed

rust/operator-binary/src/backend/cert_manager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use super::{
2020
scope::SecretScope,
2121
};
2222
use crate::{
23-
crd::v1alpha1,
23+
crd::v1alpha2,
2424
external_crd::{self, cert_manager::CertificatePrivateKey},
2525
format::SecretData,
2626
utils::Unloggable,
@@ -99,7 +99,7 @@ impl SecretBackendError for Error {
9999
pub struct CertManager {
100100
// Not secret per se, but Client isn't Debug: https://github.com/stackabletech/secret-operator/issues/411
101101
pub client: Unloggable<stackable_operator::client::Client>,
102-
pub config: v1alpha1::CertManagerBackend,
102+
pub config: v1alpha2::CertManagerBackend,
103103
}
104104

105105
#[async_trait]
@@ -160,7 +160,7 @@ impl SecretBackend for CertManager {
160160
kind: Some(self.config.issuer.kind.to_string()),
161161
},
162162
private_key: match self.config.key_generation {
163-
v1alpha1::CertificateKeyGeneration::Rsa { length } => CertificatePrivateKey {
163+
v1alpha2::CertificateKeyGeneration::Rsa { length } => CertificatePrivateKey {
164164
algorithm: "RSA".to_string(),
165165
size: length,
166166
},

rust/operator-binary/src/backend/dynamic.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use super::{
1515
pod_info::{PodInfo, SchedulingPodInfo},
1616
tls,
1717
};
18-
use crate::{crd::v1alpha1, utils::Unloggable};
18+
use crate::{crd::v1alpha2, utils::Unloggable};
1919

2020
pub struct DynError(Box<dyn SecretBackendError>);
2121

@@ -126,18 +126,18 @@ impl SecretBackendError for FromClassError {
126126

127127
pub async fn from_class(
128128
client: &stackable_operator::client::Client,
129-
class: v1alpha1::SecretClass,
129+
class: v1alpha2::SecretClass,
130130
) -> Result<Box<Dynamic>, FromClassError> {
131131
Ok(match class.spec.backend {
132-
v1alpha1::SecretClassBackend::K8sSearch(v1alpha1::K8sSearchBackend {
132+
v1alpha2::SecretClassBackend::K8sSearch(v1alpha2::K8sSearchBackend {
133133
search_namespace,
134134
trust_store_config_map_name,
135135
}) => from(super::K8sSearch {
136136
client: Unloggable(client.clone()),
137137
search_namespace,
138138
trust_store_config_map_name,
139139
}),
140-
v1alpha1::SecretClassBackend::AutoTls(v1alpha1::AutoTlsBackend {
140+
v1alpha2::SecretClassBackend::AutoTls(v1alpha2::AutoTlsBackend {
141141
ca,
142142
additional_trust_roots,
143143
max_certificate_lifetime,
@@ -150,11 +150,11 @@ pub async fn from_class(
150150
)
151151
.await?,
152152
),
153-
v1alpha1::SecretClassBackend::CertManager(config) => from(super::CertManager {
153+
v1alpha2::SecretClassBackend::CertManager(config) => from(super::CertManager {
154154
client: Unloggable(client.clone()),
155155
config,
156156
}),
157-
v1alpha1::SecretClassBackend::KerberosKeytab(v1alpha1::KerberosKeytabBackend {
157+
v1alpha2::SecretClassBackend::KerberosKeytab(v1alpha2::KerberosKeytabBackend {
158158
realm_name,
159159
kdc,
160160
admin,
@@ -182,14 +182,14 @@ pub enum FromSelectorError {
182182
#[snafu(display("failed to get {class}"))]
183183
GetSecretClass {
184184
source: stackable_operator::client::Error,
185-
class: ObjectRef<v1alpha1::SecretClass>,
185+
class: ObjectRef<v1alpha2::SecretClass>,
186186
},
187187

188188
#[snafu(display("failed to initialize backend for {class}"))]
189189
FromClass {
190190
#[snafu(source(from(FromClassError, Box::new)))]
191191
source: Box<FromClassError>,
192-
class: ObjectRef<v1alpha1::SecretClass>,
192+
class: ObjectRef<v1alpha2::SecretClass>,
193193
},
194194
}
195195

@@ -217,7 +217,7 @@ pub async fn from_selector(
217217
) -> Result<Box<Dynamic>, FromSelectorError> {
218218
let class_ref = || ObjectRef::new(&selector.class);
219219
let class = client
220-
.get::<v1alpha1::SecretClass>(&selector.class, &())
220+
.get::<v1alpha2::SecretClass>(&selector.class, &())
221221
.await
222222
.with_context(|_| from_selector_error::GetSecretClassSnafu { class: class_ref() })?;
223223
from_class(client, class)

rust/operator-binary/src/backend/k8s_search.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use super::{
2020
pod_info::{PodInfo, SchedulingPodInfo},
2121
scope::SecretScope,
2222
};
23-
use crate::{crd::v1alpha1, format::SecretData, utils::Unloggable};
23+
use crate::{crd::v1alpha2, format::SecretData, utils::Unloggable};
2424

2525
const LABEL_CLASS: &str = "secrets.stackable.tech/class";
2626
pub(super) const LABEL_SCOPE_NODE: &str = "secrets.stackable.tech/node";
@@ -89,7 +89,7 @@ impl SecretBackendError for Error {
8989
pub struct K8sSearch {
9090
// Not secret per se, but isn't Debug: https://github.com/stackabletech/secret-operator/issues/411
9191
pub client: Unloggable<stackable_operator::client::Client>,
92-
pub search_namespace: v1alpha1::SearchNamespace,
92+
pub search_namespace: v1alpha2::SearchNamespace,
9393
pub trust_store_config_map_name: Option<String>,
9494
}
9595

rust/operator-binary/src/backend/kerberos_keytab.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use super::{
2222
scope::SecretScope,
2323
};
2424
use crate::{
25-
crd::{KerberosPrincipal, v1alpha1},
25+
crd::{self, KerberosPrincipal, v1alpha2},
2626
format::{SecretData, WellKnownSecretData, well_known},
2727
utils::Unloggable,
2828
};
@@ -60,7 +60,7 @@ pub enum Error {
6060

6161
#[snafu(display("generated invalid Kerberos principal for pod"))]
6262
PodPrincipal {
63-
source: v1alpha1::InvalidKerberosPrincipal,
63+
source: crd::InvalidKerberosPrincipal,
6464
},
6565

6666
#[snafu(display("failed to read the provisioned keytab"))]
@@ -105,7 +105,7 @@ impl SecretBackendError for Error {
105105
pub struct KerberosProfile {
106106
pub realm_name: KerberosRealmName,
107107
pub kdc: HostName,
108-
pub admin: v1alpha1::KerberosKeytabBackendAdmin,
108+
pub admin: v1alpha2::KerberosKeytabBackendAdmin,
109109
}
110110

111111
#[derive(Debug)]
@@ -168,10 +168,12 @@ impl SecretBackend for KerberosKeytab {
168168
} = self;
169169

170170
let admin_server_clause = match admin {
171-
v1alpha1::KerberosKeytabBackendAdmin::Mit { kadmin_server } => {
171+
v1alpha2::KerberosKeytabBackendAdmin::Mit(v1alpha2::KerberosKeytabBackendMit {
172+
kadmin_server,
173+
}) => {
172174
format!(" admin_server = {kadmin_server}")
173175
}
174-
v1alpha1::KerberosKeytabBackendAdmin::ActiveDirectory { .. } => String::new(),
176+
v1alpha2::KerberosKeytabBackendAdmin::ActiveDirectory { .. } => String::new(),
175177
};
176178

177179
let tmp = tempdir().context(TempSetupSnafu)?;
@@ -253,24 +255,26 @@ cluster.local = {realm_name}
253255
})
254256
.collect(),
255257
admin_backend: match admin {
256-
v1alpha1::KerberosKeytabBackendAdmin::Mit { .. } => {
258+
v1alpha2::KerberosKeytabBackendAdmin::Mit { .. } => {
257259
stackable_krb5_provision_keytab::AdminBackend::Mit
258260
}
259-
v1alpha1::KerberosKeytabBackendAdmin::ActiveDirectory {
260-
ldap_server,
261-
ldap_tls_ca_secret,
262-
password_cache_secret,
263-
user_distinguished_name,
264-
schema_distinguished_name,
265-
generate_sam_account_name,
266-
} => stackable_krb5_provision_keytab::AdminBackend::ActiveDirectory {
261+
v1alpha2::KerberosKeytabBackendAdmin::ActiveDirectory(
262+
v1alpha2::KerberosKeytabBackendActiveDirectory {
263+
ldap_server,
264+
ldap_tls_ca_secret,
265+
password_cache_secret,
266+
user_distinguished_name,
267+
schema_distinguished_name,
268+
generate_sam_account_name,
269+
},
270+
) => stackable_krb5_provision_keytab::AdminBackend::ActiveDirectory {
267271
ldap_server: ldap_server.to_string(),
268272
ldap_tls_ca_secret: ldap_tls_ca_secret.clone(),
269273
password_cache_secret: password_cache_secret.clone(),
270274
user_distinguished_name: user_distinguished_name.clone(),
271275
schema_distinguished_name: schema_distinguished_name.clone(),
272276
generate_sam_account_name: generate_sam_account_name.clone().map(
273-
|v1alpha1::ActiveDirectorySamAccountNameRules {
277+
|v1alpha2::ActiveDirectorySamAccountNameRules {
274278
prefix,
275279
total_length,
276280
}| {

rust/operator-binary/src/backend/tls/ca.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use tracing::{info, info_span, warn};
3838

3939
use crate::{
4040
backend::SecretBackendError,
41-
crd::v1alpha1,
41+
crd::v1alpha2,
4242
utils::{Asn1TimeParseError, Unloggable, asn1time_to_offsetdatetime},
4343
};
4444

@@ -202,7 +202,7 @@ pub struct Config {
202202
pub rotate_if_ca_expires_before: Option<Duration>,
203203

204204
/// Configuration how TLS private keys should be created.
205-
pub key_generation: v1alpha1::CertificateKeyGeneration,
205+
pub key_generation: v1alpha2::CertificateKeyGeneration,
206206
}
207207

208208
/// A single certificate authority certificate.
@@ -241,7 +241,7 @@ impl CertificateAuthority {
241241
Conf::new(ConfMethod::default()).expect("failed to initialize OpenSSL configuration");
242242

243243
let private_key_length = match config.key_generation {
244-
v1alpha1::CertificateKeyGeneration::Rsa { length } => length,
244+
v1alpha2::CertificateKeyGeneration::Rsa { length } => length,
245245
};
246246

247247
let private_key = Rsa::generate(private_key_length)
@@ -348,7 +348,7 @@ impl Manager {
348348
pub async fn load_or_create(
349349
client: &stackable_operator::client::Client,
350350
secret_ref: &SecretReference,
351-
additional_trust_roots: &[v1alpha1::AdditionalTrustRoot],
351+
additional_trust_roots: &[v1alpha2::AdditionalTrustRoot],
352352
config: &Config,
353353
) -> Result<Self> {
354354
// Use entry API rather than apply so that we crash and retry on conflicts (to avoid creating spurious certs that we throw away immediately)
@@ -496,10 +496,10 @@ impl Manager {
496496
let mut additional_trusted_certificates = vec![];
497497
for entry in additional_trust_roots {
498498
let certs = match entry {
499-
v1alpha1::AdditionalTrustRoot::ConfigMap(config_map) => {
499+
v1alpha2::AdditionalTrustRoot::ConfigMap(config_map) => {
500500
Self::read_extra_trust_roots_from_config_map(client, config_map).await?
501501
}
502-
v1alpha1::AdditionalTrustRoot::Secret(secret) => {
502+
v1alpha2::AdditionalTrustRoot::Secret(secret) => {
503503
Self::read_extra_trust_roots_from_secret(client, secret).await?
504504
}
505505
};

rust/operator-binary/src/backend/tls/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use super::{
3333
scope::SecretScope,
3434
};
3535
use crate::{
36-
crd::v1alpha1,
36+
crd::v1alpha2,
3737
format::{SecretData, WellKnownSecretData, well_known},
3838
utils::iterator_try_concat_bytes,
3939
};
@@ -150,7 +150,7 @@ impl SecretBackendError for Error {
150150
pub struct TlsGenerate {
151151
ca_manager: ca::Manager,
152152
max_cert_lifetime: Duration,
153-
key_generation: v1alpha1::CertificateKeyGeneration,
153+
key_generation: v1alpha2::CertificateKeyGeneration,
154154
}
155155

156156
impl TlsGenerate {
@@ -162,13 +162,13 @@ impl TlsGenerate {
162162
/// an independent self-signed CA.
163163
pub async fn get_or_create_k8s_certificate(
164164
client: &stackable_operator::client::Client,
165-
v1alpha1::AutoTlsCa {
165+
v1alpha2::AutoTlsCa {
166166
secret: ca_secret,
167167
auto_generate: auto_generate_ca,
168168
ca_certificate_lifetime,
169169
key_generation,
170-
}: &v1alpha1::AutoTlsCa,
171-
additional_trust_roots: &[v1alpha1::AdditionalTrustRoot],
170+
}: &v1alpha2::AutoTlsCa,
171+
additional_trust_roots: &[v1alpha2::AdditionalTrustRoot],
172172
max_cert_lifetime: Duration,
173173
) -> Result<Self> {
174174
Ok(Self {
@@ -260,7 +260,7 @@ impl SecretBackend for TlsGenerate {
260260
Conf::new(ConfMethod::default()).expect("failed to initialize OpenSSL configuration");
261261

262262
let pod_key_length = match self.key_generation {
263-
v1alpha1::CertificateKeyGeneration::Rsa { length } => length,
263+
v1alpha2::CertificateKeyGeneration::Rsa { length } => length,
264264
};
265265

266266
let pod_key = Rsa::generate(pod_key_length)

0 commit comments

Comments
 (0)