-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #551 from cloudflare/owner-validate
Validate rule owners if configured
- Loading branch information
Showing
12 changed files
with
618 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
pint.error --no-color lint --require-owner rules | ||
! stdout . | ||
cmp stderr stderr.txt | ||
|
||
-- stderr.txt -- | ||
level=info msg="Loading configuration file" path=.pint.hcl | ||
rules/1.yml:4-5 Bug: rule/owner comments are required in all files, please add a "# pint file/owner $owner" somewhere in this file and/or "# pint rule/owner $owner" on top of each rule (rule/owner) | ||
4 | - alert: No Owner | ||
5 | expr: up > 0 | ||
|
||
rules/1.yml:7-8 Bug: this rule is set as owned by "bob" but "bob" doesn't match any of the allowed owner values (rule/owner) | ||
7 | - alert: Invalid | ||
8 | expr: up == 0 | ||
|
||
level=info msg="Problems found" Bug=2 | ||
level=fatal msg="Fatal error" error="problems found" | ||
-- rules/1.yml -- | ||
groups: | ||
- name: foo | ||
rules: | ||
- alert: No Owner | ||
expr: up > 0 | ||
# pint rule/owner bob | ||
- alert: Invalid | ||
expr: up == 0 | ||
# pint rule/owner alice | ||
- alert: Owner Alice | ||
expr: up > 0 | ||
|
||
-- .pint.hcl -- | ||
owners { | ||
allowed = ["alice", "max", "not-bob"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
http response bitbucket / 200 OK | ||
http start bitbucket 127.0.0.1:6123 | ||
|
||
mkdir testrepo | ||
cd testrepo | ||
exec git init --initial-branch=main . | ||
|
||
cp ../src/v1.yml rules.yml | ||
cp ../src/.pint.hcl . | ||
env GIT_AUTHOR_NAME=pint | ||
env [email protected] | ||
env GIT_COMMITTER_NAME=pint | ||
env [email protected] | ||
exec git add . | ||
exec git commit -am 'import rules and config' | ||
|
||
exec git checkout -b v2 | ||
cp ../src/v2.yml rules.yml | ||
exec git commit -am 'v2' | ||
|
||
env BITBUCKET_AUTH_TOKEN="12345" | ||
pint.error -l error --no-color ci --require-owner | ||
! stdout . | ||
cd .. | ||
cmp stderr stderr.txt | ||
|
||
-- stderr.txt -- | ||
rules.yml:4-5 Bug: rule/owner comments are required in all files, please add a "# pint file/owner $owner" somewhere in this file and/or "# pint rule/owner $owner" on top of each rule (rule/owner) | ||
4 | - alert: No Owner | ||
5 | expr: up > 0 | ||
|
||
rules.yml:7-8 Bug: this rule is set as owned by "bob" but "bob" doesn't match any of the allowed owner values (rule/owner) | ||
7 | - alert: Invalid | ||
8 | expr: up == 0 | ||
|
||
level=fatal msg="Fatal error" error="problems found" | ||
-- src/v1.yml -- | ||
groups: | ||
- name: foo | ||
rules: | ||
- alert: Foo | ||
expr: up > 0 | ||
- alert: Foo | ||
expr: up == 0 | ||
- alert: Foo | ||
expr: up > 0 | ||
|
||
-- src/v2.yml -- | ||
groups: | ||
- name: foo | ||
rules: | ||
- alert: No Owner | ||
expr: up > 0 | ||
# pint rule/owner bob | ||
- alert: Invalid | ||
expr: up == 0 | ||
# pint rule/owner alice | ||
- alert: Owner Alice | ||
expr: up > 0 | ||
|
||
-- src/.pint.hcl -- | ||
owners { | ||
allowed = ["alice", "max", "not-bob"] | ||
} | ||
ci { | ||
baseBranch = "main" | ||
} | ||
repository { | ||
bitbucket { | ||
uri = "http://127.0.0.1:6123" | ||
timeout = "10s" | ||
project = "prometheus" | ||
repository = "rules" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.