Skip to content

Commit

Permalink
change defineModuleFromTheChangeSet
Browse files Browse the repository at this point in the history
  • Loading branch information
Siarhei Harbuz committed Mar 12, 2024
1 parent 141c990 commit 3cf8aa0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
29 changes: 20 additions & 9 deletions .buildkite/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -404,20 +404,31 @@ defineModuleFromTheChangeSet() {
# For such, it's required to look for changes under the module folder and exclude anything else such as asciidoc and png files.
# This method defines and exports the MODULE variable with a particular module name or '' if changeset doesn't affect a specific module
local project_path=$1
local project_path_transformed=$(echo "$project_path" | sed 's/\//\\\//g')
local project_path_exclussion="((?!^${project_path_transformed}\\/).)*\$"
local exclude=("^(${project_path_exclussion}|((?!\\/module\\/).)*\$|.*\\.asciidoc|.*\\.png)")

if [[ "$project_path" == *"x-pack/"* ]]; then
local pattern=("$XPACK_MODULE_PATTERN")
else
local pattern=("$OSS_MODULE_PATTERN")
fi
local module_name="${project_path#*module/}"
local project_path_transformed=$(echo "$project_path" | sed 's/\//\\\//g')
local project_path_exclussion="((?!^${project_path_transformed}\\/).)*\$"
local exclude=("^(${project_path_transformed}|((?!\\/module\\/).)*\$|.*\\.asciidoc|.*\\.png)")
if are_paths_changed "${pattern[@]}" && ! are_changed_only_paths "${exclude[@]}"; then
export MODULE=${module_name}
elif [ -d "${project_path}" ]; then
export MODULE="aws" # TODO: remove this line and uncomment the line below when the issue https://github.com/elastic/ingest-dev/issues/2993 is solved
# export MODULE='' # TODO: uncomment the line when the issue https://github.com/elastic/ingest-dev/issues/2993 is solved
local changed_modules=""
local module_dirs=$(find "$project_path/module" -mindepth 1 -maxdepth 1 -type d)
for module_dir in $module_dirs; do
if are_paths_changed $module_dir && ! are_changed_only_paths "${exclude[@]}"; then
if [[ -z "$changed_modules" ]]; then
changed_modules=$(basename "$module_dir")
else
changed_modules+=",$(basename "$module_dir")"
fi
fi
done
if [[ -z "$changed_modules" ]]; then # TODO: remove this condition and uncomment the line below when the issue https://github.com/elastic/ingest-dev/issues/2993 is solved
export MODULE="aws"
else
export MODULE="${changed_modules}" # TODO: remove this line and uncomment the line below when the issue https://github.com/elastic/ingest-dev/issues/2993 is solved
# export MODULE="${changed_modules}" # TODO: uncomment the line when the issue https://github.com/elastic/ingest-dev/issues/2993 is solved
fi
}

Expand Down
2 changes: 0 additions & 2 deletions x-pack/metricbeat/module/aws/usage/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ input:
metrics:
- namespace: AWS/Usage
statistic: ["Sum"]
- namespace: AWS/Usage
statistic: ["Average"]

0 comments on commit 3cf8aa0

Please sign in to comment.