Skip to content

Commit

Permalink
Add docstrings to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
QU3B1M committed Jan 7, 2025
1 parent 67a71bd commit 73a0b1d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ecs/scripts/generate-pr-to-plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ PLUGINS_LOCAL_PATH=${PLUGINS_LOCAL_PATH:-"$CURRENT_PATH"/../wazuh-indexer-plugin
declare -a relevant_modules
declare -A module_to_file

# Check if a command exists on the system.
# Parameters:
# $1: Command to check.
command_exists() {
command -v "$1" &> /dev/null
}

# Validate that all required dependencies are installed.
validate_dependencies() {
local required_commands=("docker" "docker-compose" "gh")
for cmd in "${required_commands[@]}"; do
Expand All @@ -27,6 +31,7 @@ validate_dependencies() {
done
}

# Detect modified ECS modules by comparing the current branch with the base branch.
detect_modified_modules() {
echo
echo "---> Fetching and extracting modified ECS modules..."
Expand Down Expand Up @@ -71,6 +76,7 @@ detect_modified_modules() {
echo "Relevant ECS modules: ${relevant_modules[*]}"
}

# Run the ECS generator script for relevant modules.
run_ecs_generator() {
echo
echo "---> Running ECS Generator script..."
Expand All @@ -86,7 +92,7 @@ run_ecs_generator() {
fi
}


# Clone the target repository and set up GitHub authentication.
clone_target_repo() {
echo
echo "---> Cloning ${PLUGINS_REPO} repository..."
Expand All @@ -103,6 +109,7 @@ clone_target_repo() {
gh repo set-default https://"$GITHUB_TOKEN"@github.com/$PLUGINS_REPO.git
}

# Commit and push changes to the target repository.
commit_and_push_changes() {
echo
echo "---> Committing and pushing changes to ${PLUGINS_REPO} repository..."
Expand Down Expand Up @@ -145,6 +152,7 @@ commit_and_push_changes() {
fi
}

# Create or update a Pull Request with the modified ECS templates.
create_or_update_pr() {
echo
echo "---> Creating or updating Pull Request..."
Expand Down Expand Up @@ -178,6 +186,7 @@ create_or_update_pr() {
fi
}

# Display usage information.
usage() {
echo "Usage: $0 -b <BRANCH_NAME> -t <GITHUB_TOKEN>"
echo " -b [BRANCH_NAME] (Optional) Branch name to create or update the PR. Default: current branch."
Expand All @@ -186,6 +195,7 @@ usage() {
exit 1
}

# Main function
main() {
while getopts ":b:t:o:" opt; do
case ${opt} in
Expand Down

0 comments on commit 73a0b1d

Please sign in to comment.