Skip to content

Commit

Permalink
Merge pull request #1 from conduitxyz/mrozentsvayg/promtoolFlags
Browse files Browse the repository at this point in the history
Support promtool flags
  • Loading branch information
mrozentsvayg authored Oct 18, 2024
2 parents 741be6f + 9c8c739 commit 7117942
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
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

0 comments on commit 7117942

Please sign in to comment.