only append "-mappings" to component template names as needed

This commit is contained in:
reyesj2
2026-04-11 15:22:50 -05:00
parent 6298397534
commit b0584a4dc5

View File

@@ -98,6 +98,7 @@ check_heavynode_compatiable_index_template() {
load_component_templates() {
local printed_name="$1"
local pattern="${ELASTICSEARCH_TEMPLATES_DIR}/component/$2"
local append_mappings="${3:-"false"}"
# current state of nullglob shell option
shopt -q nullglob && nullglob_set=1 || nullglob_set=0
@@ -106,7 +107,13 @@ load_component_templates() {
echo -e "\nLoading $printed_name component templates...\n"
for component in "$pattern"/*.json; do
tmpl_name=$(basename "${component%.json}")
if ! load_template "_component_template/${tmpl_name}-mappings" "$component"; then
if [[ "$append_mappings" == "true" ]]; then
# avoid duplicating "-mappings" if it already exists in the component template filename
tmpl_name="${tmpl_name%-mappings}-mappings"
fi
if ! load_template "_component_template/${tmpl_name}" "$component"; then
LOAD_FAILURES=$((LOAD_FAILURES + 1))
LOAD_FAILURES_NAMES+=("$component")
fi
@@ -138,9 +145,9 @@ if [[ "$FORCE" == "true" || ! -f "$SO_STATE_FILE_SUCCESS" ]]; then
fi
fi
load_component_templates "ECS" "ecs"
load_component_templates "ECS" "ecs" "true"
load_component_templates "Elastic Agent" "elastic-agent"
load_component_templates "Security Onion" "securityonion"
load_component_templates "Security Onion" "so"
component_templates=$(so-elasticsearch-component-templates-list)
echo -e "Loading Security Onion index templates...\n"
@@ -187,4 +194,4 @@ else
echo "Templates already loaded"
fi
fi