forked from stackabletech/hive-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.rs
More file actions
69 lines (62 loc) · 2.91 KB
/
Copy pathcommand.rs
File metadata and controls
69 lines (62 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use stackable_operator::crd::s3;
use crate::{
config::opa::HiveOpaConfig,
crd::{
HIVE_METASTORE_LOG4J2_PROPERTIES, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_MOUNT_DIR,
STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_TRUST_STORE, STACKABLE_TRUST_STORE_PASSWORD,
v1alpha1,
},
};
pub fn build_container_command_args(
hive: &v1alpha1::HiveCluster,
start_command: String,
s3_connection_spec: Option<&s3::v1alpha1::ConnectionSpec>,
hive_opa_config: Option<&HiveOpaConfig>,
) -> Vec<String> {
let mut args = vec![
// copy config files to a writeable empty folder in order to set s3 access and secret keys
format!("echo copying {STACKABLE_CONFIG_MOUNT_DIR} to {STACKABLE_CONFIG_DIR}"),
format!("cp -RL {STACKABLE_CONFIG_MOUNT_DIR}/* {STACKABLE_CONFIG_DIR}"),
// Copy log4j2 properties
format!(
"echo copying {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES} to {STACKABLE_CONFIG_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES}"
),
format!(
"cp -RL {STACKABLE_LOG_CONFIG_MOUNT_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES} {STACKABLE_CONFIG_DIR}/{HIVE_METASTORE_LOG4J2_PROPERTIES}"
),
// Template config files
format!(
"if test -f {STACKABLE_CONFIG_DIR}/core-site.xml; then config-utils template {STACKABLE_CONFIG_DIR}/core-site.xml; fi"
),
format!(
"if test -f {STACKABLE_CONFIG_DIR}/hive-site.xml; then config-utils template {STACKABLE_CONFIG_DIR}/hive-site.xml; fi"
),
// Copy system truststore to stackable truststore
format!(
"cert-tools generate-pkcs12-truststore --pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem --out {STACKABLE_TRUST_STORE} --out-password {STACKABLE_TRUST_STORE_PASSWORD}"
),
];
if hive.spec.cluster_config.hdfs.is_some() {
args.extend([
format!("echo copying /stackable/mount/hdfs-config to {STACKABLE_CONFIG_DIR}"),
format!("cp -RL /stackable/mount/hdfs-config/* {STACKABLE_CONFIG_DIR}"),
]);
}
if let Some(s3) = s3_connection_spec
&& let Some(ca_cert_file) = s3.tls.tls_ca_cert_mount_path()
{
args.push(format!(
"cert-tools generate-pkcs12-truststore --pkcs12 {STACKABLE_TRUST_STORE}:{STACKABLE_TRUST_STORE_PASSWORD} --pem {ca_cert_file} --out {STACKABLE_TRUST_STORE} --out-password {STACKABLE_TRUST_STORE_PASSWORD}"
));
}
if let Some(opa) = hive_opa_config
&& let Some(ca_cert_dir) = opa.tls_ca_cert_mount_path()
{
args.push(format!(
"cert-tools generate-pkcs12-truststore --pkcs12 {STACKABLE_TRUST_STORE}:{STACKABLE_TRUST_STORE_PASSWORD} --pem {ca_cert_dir}/ca.crt --out {STACKABLE_TRUST_STORE} --out-password {STACKABLE_TRUST_STORE_PASSWORD}"
));
}
// metastore start command
args.push(start_command);
vec![args.join("\n")]
}