mirror of
https://github.com/wazuh/wazuh-indexer-plugins.git
synced 2025-12-10 14:32:28 -06:00
Automatically regenerate dependant stateless modules on base module change (#618)
* Add -f (force) flag * Propagate changes from stateless * Update CHANGELOG.md
This commit is contained in:
parent
e4a5466caa
commit
ad30d6609f
@ -46,6 +46,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
- Bump WCS to ECS v9.1.0 [(#600)](https://github.com/wazuh/wazuh-indexer-plugins/pull/600)
|
||||
- Replace genai.* nested fields with keyword array [(#608)](https://github.com/wazuh/wazuh-indexer-plugins/pull/608)
|
||||
- Check GitHub actions with dependabot [(#601)](https://github.com/wazuh/wazuh-indexer-plugins/pull/601)
|
||||
- Automatically regenerate dependant stateless modules on base module change [(#618)](https://github.com/wazuh/wazuh-indexer-plugins/pull/618)
|
||||
|
||||
### Deprecated
|
||||
-
|
||||
|
||||
@ -14,6 +14,7 @@ set -euo pipefail
|
||||
# Global variables
|
||||
declare -a modules_to_update
|
||||
declare -A module_to_file
|
||||
declare force_update=false
|
||||
|
||||
# ====
|
||||
# Checks that the script is run from the intended location
|
||||
@ -65,8 +66,14 @@ function detect_modified_modules() {
|
||||
echo
|
||||
echo "---> Modified modules"
|
||||
modules_to_update=()
|
||||
|
||||
local stateless_found=false
|
||||
|
||||
for ecs_module in "${modified_modules[@]}"; do
|
||||
echo " - $ecs_module"
|
||||
if [[ "$ecs_module" == "stateless" ]]; then
|
||||
stateless_found=true
|
||||
fi
|
||||
if [[ ! -v module_to_file[$ecs_module] ]]; then
|
||||
echo "Warning: Module '$ecs_module' not found in module list. Probably removed. Skipping."
|
||||
continue
|
||||
@ -75,6 +82,16 @@ function detect_modified_modules() {
|
||||
modules_to_update+=("$ecs_module")
|
||||
fi
|
||||
done
|
||||
if [[ "$stateless_found" == true ]]; then
|
||||
# Add all module keys starting with 'stateless-' to modules_to_update (avoid duplicates)
|
||||
for key in "${!module_to_file[@]}"; do
|
||||
if [[ "$key" == stateless-* ]]; then
|
||||
if [[ ! " ${modules_to_update[*]} " =~ " $key " ]]; then
|
||||
modules_to_update+=("$key")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# ====
|
||||
@ -146,7 +163,10 @@ function copy_files() {
|
||||
# Display usage information.
|
||||
# ====
|
||||
function usage() {
|
||||
echo "Usage: $0"
|
||||
echo "Usage: $0
|
||||
Options:
|
||||
-h Show this help message
|
||||
-f Force update all modules"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@ -154,8 +174,12 @@ function usage() {
|
||||
# Main function.
|
||||
# ====
|
||||
function main() {
|
||||
while getopts ":h" arg; do
|
||||
while getopts ":fh" arg; do
|
||||
case ${arg} in
|
||||
f)
|
||||
# Force update all modules
|
||||
force_update=true
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
@ -184,7 +208,12 @@ function main() {
|
||||
fi
|
||||
|
||||
navigate_to_project_root
|
||||
detect_modified_modules
|
||||
if [ "$force_update" = true ]; then
|
||||
echo "Force update enabled. All modules will be updated."
|
||||
modules_to_update=("${!module_to_file[@]}")
|
||||
else
|
||||
detect_modified_modules
|
||||
fi
|
||||
update_modified_modules
|
||||
copy_files "$repo_path"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user