Merge pull request #29 from fluxcd/update-schema-0.5.0 #40
This file contains hidden or 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
| name: validate-catalog | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Setup Go | |
| uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | |
| with: | |
| go-version-file: cmd/validate/go.mod | |
| cache-dependency-path: cmd/validate/go.sum | |
| - name: Validate schemas | |
| run: make validate | |
| - name: Validate catalog consistency | |
| run: | | |
| failed=0 | |
| # Every plugin file must have a corresponding catalog entry | |
| for file in plugins/*.yaml; do | |
| name=$(basename "$file" .yaml) | |
| entry=$(yq ".plugins[] | select(.name == \"$name\")" catalog.yaml) | |
| if [ -z "$entry" ]; then | |
| echo "ERROR: plugin '$name' not found in catalog.yaml" | |
| failed=1 | |
| fi | |
| done | |
| # Every catalog entry must have a corresponding plugin file | |
| count=$(yq '.plugins | length' catalog.yaml) | |
| for ((i=0; i<count; i++)); do | |
| name=$(yq ".plugins[$i].name" catalog.yaml) | |
| if [ ! -f "plugins/${name}.yaml" ]; then | |
| echo "ERROR: catalog entry '$name' has no matching plugins/${name}.yaml" | |
| failed=1 | |
| fi | |
| # Name must not collide with builtins | |
| for reserved in bootstrap build catalog check completion create debug delete diff envsubst events export get help install list logs migrate plugin pull push reconcile resume stats suspend tag trace tree uninstall version; do | |
| if [ "$name" = "$reserved" ]; then | |
| echo "ERROR: catalog entry '$name' collides with built-in command" | |
| failed=1 | |
| fi | |
| done | |
| done | |
| if [ "$failed" -ne 0 ]; then | |
| exit 1 | |
| fi | |
| echo "Catalog consistency check passed" |