Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support promtool flags #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
with:
promtool_actions_subcommand: 'rules'
promtool_actions_files: 'prometheus/alert_rules/*.yml'
promtool_actions_flags: '--lint-fatal'
promtool_actions_version: '2.14.0'
promtool_actions_comment: true
env:
Expand All @@ -57,6 +58,7 @@ Inputs configure Terraform GitHub Actions to perform different actions.

* `promtool_actions_subcommand` - (Required) The Promtool subcommand to execute. Valid values are `rules` and `config`.
* `promtool_actions_files` - (Required) Path to files. Can be something like `configs/*.yml` or `alert_rules/*.yml`.
* `promtool_actions_flags` - (Optional) The Promtool flags.
* `promtool_actions_version` - (Optional) The Promtool version to install and execute (Prometheus bundle version). The default is set to `latest` and the latest stable version will be pulled down automatically.
* `promtool_actions_comment` - (Optional) Whether or not to comment on GitHub pull requests. Defaults to `true`.

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
promtool_actions_files:
description: 'Path to files. Can be something like `configs/*.yml` or `alert_rules/*.yml`.'
required: true
promtool_actions_flags:
description: 'Promtool flags.'
default: ''
promtool_actions_version:
description: 'Promtool version to install.'
default: 'latest'
Expand Down
5 changes: 5 additions & 0 deletions src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ function parseInputs {
exit 1
fi

promtoolFlags=""
if [ "${INPUT_PROMTOOL_ACTIONS_FLAGS}" != "" ]; then
promtoolFlags=${INPUT_PROMTOOL_ACTIONS_FLAGS}
fi

# Optional inputs
promtoolVersion="latest"
if [ "${INPUT_PROMTOOL_ACTIONS_VERSION}" != "" ] || [ "${INPUT_PROMTOOL_ACTIONS_VERSION}" != "latest" ]; then
Expand Down
2 changes: 1 addition & 1 deletion src/promtool_check_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function promtoolCheckConfig {
echo "rules: info: checking if Prometheus config files are valid or not"
checkconfigOut=$(promtool check config ${promFiles} ${*} 2>&1)
checkconfigOut=$(promtool check config ${promtoolFlags} ${promFiles} ${*} 2>&1)
checkconfigExitCode=${?}

# Exit code of 0 indicates success. Print the output and exit.
Expand Down
2 changes: 1 addition & 1 deletion src/promtool_check_rules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function promtoolCheckRules {
echo "rules: info: checking if Prometheus alert rule files are valid or not"
checkRulesOut=$(promtool check rules ${promFiles} ${*} 2>&1)
checkRulesOut=$(promtool check rules ${promtoolFlags} ${promFiles} ${*} 2>&1)
checkRulesExitCode=${?}

# Exit code of 0 indicates success. Print the output and exit.
Expand Down