Skip to content

Commit 077d2bb

Browse files
committed
rename struct
1 parent ccbfa4b commit 077d2bb

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use tracing::{info, info_span, warn};
3434

3535
use crate::{
3636
backend::SecretBackendError,
37-
crd::TlsKeyGeneration,
37+
crd::CertificateKeyGeneration,
3838
utils::{asn1time_to_offsetdatetime, Asn1TimeParseError, Unloggable},
3939
};
4040

@@ -156,7 +156,7 @@ pub struct Config {
156156
pub rotate_if_ca_expires_before: Option<Duration>,
157157

158158
/// Configuration how TLS private keys should be created.
159-
pub key_generation: TlsKeyGeneration,
159+
pub key_generation: CertificateKeyGeneration,
160160
}
161161

162162
/// A single certificate authority certificate.
@@ -194,7 +194,7 @@ impl CertificateAuthority {
194194
let conf = Conf::new(ConfMethod::default()).unwrap();
195195

196196
let private_key_length = match config.key_generation {
197-
TlsKeyGeneration::Rsa { length } => length,
197+
CertificateKeyGeneration::Rsa { length } => length,
198198
};
199199

200200
let private_key = Rsa::generate(private_key_length)

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use stackable_operator::{
2828
use time::OffsetDateTime;
2929

3030
use crate::{
31-
crd::{self, TlsKeyGeneration},
31+
crd::{self, CertificateKeyGeneration},
3232
format::{well_known, SecretData, WellKnownSecretData},
3333
utils::iterator_try_concat_bytes,
3434
};
@@ -132,7 +132,7 @@ impl SecretBackendError for Error {
132132
pub struct TlsGenerate {
133133
ca_manager: ca::Manager,
134134
max_cert_lifetime: Duration,
135-
key_generation: TlsKeyGeneration,
135+
key_generation: CertificateKeyGeneration,
136136
}
137137

138138
impl TlsGenerate {
@@ -239,7 +239,7 @@ impl SecretBackend for TlsGenerate {
239239
let conf = Conf::new(ConfMethod::default()).unwrap();
240240

241241
let pod_key_length = match self.key_generation {
242-
TlsKeyGeneration::Rsa { length } => length,
242+
CertificateKeyGeneration::Rsa { length } => length,
243243
};
244244

245245
let pod_key = Rsa::generate(pod_key_length)

rust/operator-binary/src/crd.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub struct AutoTlsCa {
127127
/// The algorithm used to generate a keypair and required configuration settings.
128128
/// Currently only RSA and a key length of 2048, 3072 or 4096 bits can be configured.
129129
#[serde(default)]
130-
pub key_generation: TlsKeyGeneration,
130+
pub key_generation: CertificateKeyGeneration,
131131
}
132132

133133
impl AutoTlsCa {
@@ -138,19 +138,19 @@ impl AutoTlsCa {
138138

139139
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
140140
#[serde(rename_all = "camelCase")]
141-
pub enum TlsKeyGeneration {
141+
pub enum CertificateKeyGeneration {
142142
Rsa {
143143
/// The amount of bits used for key or certs. Currently, `2048`, `3072` and `4096` are
144144
/// supported. Defaults to `2048` bits.
145-
#[schemars(schema_with = "TlsKeyGeneration::tls_key_length_schema")]
145+
#[schemars(schema_with = "CertificateKeyGeneration::tls_key_length_schema")]
146146
length: u32,
147147
},
148148
}
149149

150-
impl TlsKeyGeneration {
151-
pub const TLS_RSA_KEY_LENGTH_2048: u32 = 2048;
152-
pub const TLS_RSA_KEY_LENGTH_3072: u32 = 3072;
153-
pub const TLS_RSA_KEY_LENGTH_4096: u32 = 4096;
150+
impl CertificateKeyGeneration {
151+
pub const RSA_KEY_LENGTH_2048: u32 = 2048;
152+
pub const RSA_KEY_LENGTH_3072: u32 = 3072;
153+
pub const RSA_KEY_LENGTH_4096: u32 = 4096;
154154

155155
// Could not get a "standard" enum with assigned values/discriminants to work as integers in the schema
156156
// The following was generated and requires the length to be provided as string (we want an integer)
@@ -174,19 +174,19 @@ impl TlsKeyGeneration {
174174
serde_json::from_value(serde_json::json!({
175175
"type": "integer",
176176
"enum": [
177-
Self::TLS_RSA_KEY_LENGTH_2048,
178-
Self::TLS_RSA_KEY_LENGTH_3072,
179-
Self::TLS_RSA_KEY_LENGTH_4096
177+
Self::RSA_KEY_LENGTH_2048,
178+
Self::RSA_KEY_LENGTH_3072,
179+
Self::RSA_KEY_LENGTH_4096
180180
]
181181
}))
182182
.expect("Failed to parse JSON of custom tls key length schema")
183183
}
184184
}
185185

186-
impl Default for TlsKeyGeneration {
186+
impl Default for CertificateKeyGeneration {
187187
fn default() -> Self {
188188
Self::Rsa {
189-
length: Self::TLS_RSA_KEY_LENGTH_2048,
189+
length: Self::RSA_KEY_LENGTH_2048,
190190
}
191191
}
192192
}
@@ -446,8 +446,8 @@ mod test {
446446
},
447447
auto_generate: false,
448448
ca_certificate_lifetime: DEFAULT_CA_CERT_LIFETIME,
449-
key_generation: TlsKeyGeneration::Rsa {
450-
length: TlsKeyGeneration::TLS_RSA_KEY_LENGTH_3072
449+
key_generation: CertificateKeyGeneration::Rsa {
450+
length: CertificateKeyGeneration::RSA_KEY_LENGTH_3072
451451
}
452452
},
453453
max_certificate_lifetime: DEFAULT_MAX_CERT_LIFETIME,
@@ -485,7 +485,7 @@ mod test {
485485
},
486486
auto_generate: true,
487487
ca_certificate_lifetime: Duration::from_days_unchecked(100),
488-
key_generation: TlsKeyGeneration::default()
488+
key_generation: CertificateKeyGeneration::default()
489489
},
490490
max_certificate_lifetime: Duration::from_days_unchecked(31),
491491
})

0 commit comments

Comments
 (0)