Skip to content

Commit 2426b77

Browse files
committed
fix: consolidate constants
1 parent f2f757c commit 2426b77

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

rust/operator-binary/src/crd/security.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ impl ZookeeperSecurity {
6969
pub const SERVER_CNXN_FACTORY: &'static str = "serverCnxnFactory";
7070
pub const SERVER_TLS_DIR: &'static str = "/stackable/server_tls";
7171
pub const SERVER_TLS_MOUNT_DIR: &'static str = "/stackable/server_tls_mount";
72+
// TLS volume names (the mount name must match the volume name)
73+
pub const SERVER_TLS_VOLUME_NAME: &'static str = "server-tls";
74+
pub const QUORUM_TLS_VOLUME_NAME: &'static str = "quorum-tls";
75+
// TLS store file names (relative to the respective TLS dir)
76+
pub const KEYSTORE_FILE: &'static str = "keystore.p12";
77+
pub const TRUSTSTORE_FILE: &'static str = "truststore.p12";
7278
// Common TLS
7379
pub const SSL_AUTH_PROVIDER_X509: &'static str = "authProvider.x509";
7480
// Client TLS
@@ -150,7 +156,7 @@ impl ZookeeperSecurity {
150156
let tls_secret_class = self.get_tls_secret_class();
151157

152158
if let Some(secret_class) = tls_secret_class {
153-
let tls_volume_name = "server-tls";
159+
let tls_volume_name = Self::SERVER_TLS_VOLUME_NAME;
154160
cb_zookeeper
155161
.add_volume_mount(tls_volume_name, Self::SERVER_TLS_DIR)
156162
.context(AddVolumeMountSnafu)?;
@@ -164,7 +170,7 @@ impl ZookeeperSecurity {
164170
}
165171

166172
// quorum
167-
let tls_volume_name = "quorum-tls";
173+
let tls_volume_name = Self::QUORUM_TLS_VOLUME_NAME;
168174
cb_zookeeper
169175
.add_volume_mount(tls_volume_name, Self::QUORUM_TLS_DIR)
170176
.context(AddVolumeMountSnafu)?;
@@ -202,11 +208,19 @@ impl ZookeeperSecurity {
202208
// and written later via script in the init container
203209
config.insert(
204210
Self::SSL_QUORUM_KEY_STORE_LOCATION.to_string(),
205-
format!("{dir}/keystore.p12", dir = Self::QUORUM_TLS_DIR),
211+
format!(
212+
"{dir}/{file}",
213+
dir = Self::QUORUM_TLS_DIR,
214+
file = Self::KEYSTORE_FILE
215+
),
206216
);
207217
config.insert(
208218
Self::SSL_QUORUM_TRUST_STORE_LOCATION.to_string(),
209-
format!("{dir}/truststore.p12", dir = Self::QUORUM_TLS_DIR),
219+
format!(
220+
"{dir}/{file}",
221+
dir = Self::QUORUM_TLS_DIR,
222+
file = Self::TRUSTSTORE_FILE
223+
),
210224
);
211225

212226
// Server TLS
@@ -255,11 +269,19 @@ impl ZookeeperSecurity {
255269
// and written later via script in the init container
256270
config.insert(
257271
Self::SSL_KEY_STORE_LOCATION.to_string(),
258-
format!("{dir}/keystore.p12", dir = Self::SERVER_TLS_DIR),
272+
format!(
273+
"{dir}/{file}",
274+
dir = Self::SERVER_TLS_DIR,
275+
file = Self::KEYSTORE_FILE
276+
),
259277
);
260278
config.insert(
261279
Self::SSL_TRUST_STORE_LOCATION.to_string(),
262-
format!("{dir}/truststore.p12", dir = Self::SERVER_TLS_DIR),
280+
format!(
281+
"{dir}/{file}",
282+
dir = Self::SERVER_TLS_DIR,
283+
file = Self::TRUSTSTORE_FILE
284+
),
263285
);
264286
// Check if we need to enable client TLS authentication
265287
if self

0 commit comments

Comments
 (0)