Skip to content

Commit db3a753

Browse files
committed
fix: move hardcoded reused values to constants
1 parent f905635 commit db3a753

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

rust/operator-binary/src/controller/build/kerberos.rs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use stackable_operator::{
1717

1818
use crate::{
1919
controller::ValidatedCluster,
20-
crd::{TLS_STORE_DIR, TLS_STORE_PASSWORD, TLS_STORE_VOLUME_NAME},
20+
crd::{TLS_STORE_DIR, TLS_STORE_PASSWORD, TLS_STORE_TYPE, TLS_STORE_VOLUME_NAME},
2121
};
2222

2323
/// Mount path of the Kerberos secret volume (keytab + `krb5.conf`).
@@ -27,6 +27,8 @@ pub const STACKABLE_KERBEROS_DIR: &str = "/stackable/kerberos";
2727
pub const KRB5_CONFIG_PATH: &str = const_format::concatcp!(STACKABLE_KERBEROS_DIR, "/krb5.conf");
2828
/// Name of the Kerberos secret volume.
2929
const KERBEROS_VOLUME_NAME: &str = "kerberos";
30+
/// The RPC/data-transfer quality-of-protection level used when Kerberos is enabled.
31+
const PROTECTION_PRIVACY: &str = "privacy";
3032

3133
#[derive(Snafu, Debug)]
3234
pub enum Error {
@@ -66,26 +68,29 @@ pub fn kerberos_config_properties(
6668
"hbase.security.authorization".to_string(),
6769
"true".to_string(),
6870
),
69-
("hbase.rpc.protection".to_string(), "privacy".to_string()),
71+
(
72+
"hbase.rpc.protection".to_string(),
73+
PROTECTION_PRIVACY.to_string(),
74+
),
7075
(
7176
"dfs.data.transfer.protection".to_string(),
72-
"privacy".to_string(),
77+
PROTECTION_PRIVACY.to_string(),
7378
),
7479
(
7580
"hbase.rpc.engine".to_string(),
7681
"org.apache.hadoop.hbase.ipc.SecureRpcEngine".to_string(),
7782
),
7883
(
7984
"hbase.master.keytab.file".to_string(),
80-
"/stackable/kerberos/keytab".to_string(),
85+
format!("{STACKABLE_KERBEROS_DIR}/keytab"),
8186
),
8287
(
8388
"hbase.regionserver.keytab.file".to_string(),
84-
"/stackable/kerberos/keytab".to_string(),
89+
format!("{STACKABLE_KERBEROS_DIR}/keytab"),
8590
),
8691
(
8792
"hbase.rest.keytab.file".to_string(),
88-
"/stackable/kerberos/keytab".to_string(),
93+
format!("{STACKABLE_KERBEROS_DIR}/keytab"),
8994
),
9095
(
9196
"hbase.coprocessor.master.classes".to_string(),
@@ -101,7 +106,7 @@ pub fn kerberos_config_properties(
101106
("hbase.rest.authentication.kerberos.principal".to_string(), format!(
102107
"HTTP/{principal_host_part}"
103108
)),
104-
("hbase.rest.authentication.kerberos.keytab".to_string(), "/stackable/kerberos/keytab".to_string()),
109+
("hbase.rest.authentication.kerberos.keytab".to_string(), format!("{STACKABLE_KERBEROS_DIR}/keytab")),
105110

106111
// Enabled https as well
107112
("hbase.ssl.enabled".to_string(), "true".to_string()),
@@ -114,7 +119,7 @@ pub fn kerberos_config_properties(
114119
("hbase.rest.ssl.enabled".to_string(), "true".to_string()),
115120
("hbase.rest.ssl.keystore.store".to_string(), format!("{TLS_STORE_DIR}/keystore.p12")),
116121
("hbase.rest.ssl.keystore.password".to_string(), TLS_STORE_PASSWORD.to_string()),
117-
("hbase.rest.ssl.keystore.type".to_string(), "pkcs12".to_string()),
122+
("hbase.rest.ssl.keystore.type".to_string(), TLS_STORE_TYPE.to_string()),
118123
]);
119124
config.extend(kerberos_principals(&principal_host_part));
120125
config
@@ -132,7 +137,10 @@ pub fn kerberos_discovery_config_properties(
132137
"hbase.security.authentication".to_string(),
133138
"kerberos".to_string(),
134139
),
135-
("hbase.rpc.protection".to_string(), "privacy".to_string()),
140+
(
141+
"hbase.rpc.protection".to_string(),
142+
PROTECTION_PRIVACY.to_string(),
143+
),
136144
("hbase.ssl.enabled".to_string(), "true".to_string()),
137145
]);
138146
config.extend(kerberos_principals(&principal_host_part));
@@ -146,7 +154,10 @@ pub fn kerberos_ssl_server_settings() -> BTreeMap<String, String> {
146154
"ssl.server.keystore.location".to_string(),
147155
format!("{TLS_STORE_DIR}/keystore.p12"),
148156
),
149-
("ssl.server.keystore.type".to_string(), "pkcs12".to_string()),
157+
(
158+
"ssl.server.keystore.type".to_string(),
159+
TLS_STORE_TYPE.to_string(),
160+
),
150161
(
151162
"ssl.server.keystore.password".to_string(),
152163
TLS_STORE_PASSWORD.to_string(),
@@ -250,7 +261,10 @@ fn truststore_settings(role: &str) -> BTreeMap<String, String> {
250261
format!("ssl.{role}.truststore.location"),
251262
format!("{TLS_STORE_DIR}/truststore.p12"),
252263
),
253-
(format!("ssl.{role}.truststore.type"), "pkcs12".to_string()),
264+
(
265+
format!("ssl.{role}.truststore.type"),
266+
TLS_STORE_TYPE.to_string(),
267+
),
254268
(
255269
format!("ssl.{role}.truststore.password"),
256270
TLS_STORE_PASSWORD.to_string(),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ pub const CONFIG_DIR_NAME: &str = "/stackable/conf";
5252
pub const TLS_STORE_DIR: &str = "/stackable/tls";
5353
pub const TLS_STORE_VOLUME_NAME: &str = "tls";
5454
pub const TLS_STORE_PASSWORD: &str = "changeit";
55+
/// The key- and truststore type used for all HBase TLS stores.
56+
pub const TLS_STORE_TYPE: &str = "pkcs12";
5557

5658
pub const JVM_SECURITY_PROPERTIES_FILE: &str = "security.properties";
5759

0 commit comments

Comments
 (0)