Skip to content

Commit 63fbded

Browse files
Move init-keystore script into separate file
1 parent 771bd5b commit 63fbded

2 files changed

Lines changed: 17 additions & 26 deletions

File tree

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

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ impl<'a> RoleGroupBuilder<'a> {
425425
if self.cluster.keystores.is_empty() {
426426
return None;
427427
}
428+
428429
let opensearch_home = self.node_config.opensearch_home();
429430
let mut volume_mounts = vec![VolumeMount {
430431
mount_path: format!(
@@ -450,21 +451,8 @@ impl<'a> RoleGroupBuilder<'a> {
450451
Some(
451452
new_container_builder(&v1alpha1::Container::InitKeystore.to_container_name())
452453
.image_from_product_image(&self.cluster.image)
453-
.command(vec![
454-
"/bin/bash".to_string(),
455-
"-x".to_string(),
456-
"-euo".to_string(),
457-
"pipefail".to_string(),
458-
"-c".to_string(),
459-
])
460-
.args(vec![format!(
461-
"bin/opensearch-keystore create
462-
for i in keystore-secrets/*; do
463-
key=$(basename $i)
464-
bin/opensearch-keystore add-file \"$key\" \"$i\"
465-
done
466-
cp --archive config/opensearch.keystore {OPENSEARCH_INITIALIZED_KEYSTORE_DIRECTORY_NAME}",
467-
)])
454+
.command(vec!["/bin/bash".to_owned(), "-c".to_owned()])
455+
.args(vec![include_str!("scripts/init-keystore.sh").to_owned()])
468456
.add_volume_mounts(volume_mounts)
469457
.expect("The mount paths are statically defined and there should be no duplicates.")
470458
.resources(self.role_group_config.config.resources.clone().into())
@@ -1864,20 +1852,10 @@ mod tests {
18641852
"initContainers": [
18651853
{
18661854
"args": [
1867-
concat!(
1868-
"bin/opensearch-keystore create\n",
1869-
"for i in keystore-secrets/*; do\n",
1870-
" key=$(basename $i)\n",
1871-
" bin/opensearch-keystore add-file \"$key\" \"$i\"\n",
1872-
"done\n",
1873-
"cp --archive config/opensearch.keystore initialized-keystore"
1874-
),
1855+
include_str!("scripts/init-keystore.sh")
18751856
],
18761857
"command": [
18771858
"/bin/bash",
1878-
"-x",
1879-
"-euo",
1880-
"pipefail",
18811859
"-c"
18821860
],
18831861
"image": "oci.stackable.tech/sdp/opensearch:3.4.0-stackable0.0.0-dev",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -e -u -x -o pipefail
4+
5+
bin/opensearch-keystore create
6+
7+
for i in keystore-secrets/*
8+
do
9+
key=$(basename "$i")
10+
bin/opensearch-keystore add-file "$key" "$i"
11+
done
12+
13+
cp --archive config/opensearch.keystore initialized-keystore

0 commit comments

Comments
 (0)