Small binary to validate the CODEOWNERS file and check if a path matches a CODEOWNER entry. Useful for using on CI to ensure CODEOWNERS coverage.
Available at: Docker Hub and Quay.io.
You can change build arguments for GOOS and GOARCH using --build-arg GOOS=linux --build-arg GOARCH=arm
.
codeowners-verifier verifies the entries inside a CODEOWNERS file. At the time being, it only supports Gitlab Code Owners. Although CodeOwners works the same way for Gitlab and Github (the same validation checks are done by both), Wildlife's implementation also checks for valid Users and Groups inside a CODEOWNERS file.
CODEOWNER_PROVIDER_URL
: The URL to the chosen provider. Each provider will have a default value.CODEOWNER_PROVIDER_TOKEN
: Token to authenticate toward the chosen provider. There isn't default.CODEOWNER_PATH
: Path to the CODEOWNERS file. There isn't a default.
Those environment variables may also be defined by the respective flags: --base-url
, --codeowners
and --token
.
A combination of using both flags and environment variables is possible, but keep in mind that flag values override environment variables values.
There are three verbs available: help
, verify
and validate
.
Help displays basic help message on the available verbs and global flags. Can also be used to get help on the available verbs:
./codeowners-verifier help verify
Verify must receive a path as argument. It then checks if the given path is covered by any of the existing entries.
Example:
codeowners-verifier verify dir1/
INFO[0000] Found matching rule on line 7: /**/ [@group1]
Verify supports the -i (--ignore)
flag to ignore users/groups. It can be used multiples times and/or by a comma separated list of groups/users.
codeowners-verifier verify dir1/ -i @user1 --ignore @user2
INFO[0000] Found matching rule on line 7: /**/ [@group1]
codeowners-verifier verify dir1/ -i @user1 -i @user2,@group1
FATA[0000] Missing CODEOWNER entry, matched rule from line 7 don't have valid owners: /**/ [@group1]. Check your ignore rules.
Validate validates the entire CODEOWNERS file, checking if the users and/or groups are valid. It does that by checking if the user or group is valid on the provider API.
It must receive the name of the provider. YOu can check for the available providers by executing the help:
codeowners-verifier validate -h
Then, execute with the provider name:
codeowners-verifier validate gitlab
INFO[0007] Valid CODEOWNERS file
In case something is wrong:
codeowners-verifier validate gitlab
ERRO[0007] Error parsing line 7: user/group @user1 is invalid
ERRO[0007] Error parsing line 8, path test-dir/ does not exist
ERRO[0008] Error parsing line 8: user/group @group1 is invalid
ERRO[0008] Error parsing line 8: user/group @group2 is invalid
FATA[0008] Invalid CODEOWNERS file