Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Bouquillon committed Oct 3, 2023
1 parent ecaa2a3 commit 242b9d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/jsonschema/jsonschema-valid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ unknown:
hello: world

some-chart:
~chart: pouet
~chart: xxx
hello: world

some-app:
Expand Down
40 changes: 6 additions & 34 deletions .github/workflows/tests-jsonschema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,18 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3

- uses: actions/setup-node@v3
- uses: actions/setup-python@v4
with:
node-version: 20
cache: "yarn"

python-version: "3.10"
- name: install
run: |
# fetch kube json-schema locally and add $id for schema resolution
sudo apt-get update -y
mkdir external-schemas
curl https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json | jq '. + {"$id": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json"}' > external-schemas/kube.json
curl https://raw.githubusercontent.com/socialgouv/helm-charts/v1/charts/cnpg-cluster/values.schema.json > external-schemas/cnpg-cluster.schema.json
curl https://raw.githubusercontent.com/socialgouv/kontinuous/v1/plugins/contrib/charts/app/kontinuous.values.schema.json > external-schemas/app.schema.json
curl https://raw.githubusercontent.com/socialgouv/helm-charts/v1/charts/pgweb/values.schema.json > external-schemas/pgweb.schema.json
curl https://raw.githubusercontent.com/socialgouv/helm-charts/v1/charts/maildev/values.schema.json > external-schemas/maildev.schema.json
curl https://raw.githubusercontent.com/SocialGouv/json-schemas/main/postgres/parameters.json > external-schemas/postgres-parameters.schema.json
curl https://raw.githubusercontent.com/SocialGouv/json-schemas/main/postgres/extensions.json > external-schemas/postgres-extensions.schema.json
curl https://raw.githubusercontent.com/SocialGouv/json-schemas/main/nginx/annotations.schema.json > external-schemas/nginx-annotations.schema.json
pip install pipx
pipx install check-jsonschema
- name: test valid schema
run: |
AJV_PARAMS='--spec draft7 --allow-union-types --strict=false --all-errors --errors=json --validate-formats=false -r "plugins/**/*.schema.json" -r "./external-schemas/**.json"'
echo "jsonschema-valid.yaml should have no error"
cat .github/jsonschema/jsonschema-valid.yml | yq -o=json > jsonschema-valid.json
RES=$(npx ajv-cli validate -s ./docs/values.schema.json -d jsonschema-valid.json $AJV_PARAMS)
if [ "$RES" == "jsonschema-valid.json valid" ]; then
echo "Valid schema"
else
echo "Invalid schema"
exit 1
fi
check-jsonschema .github/jsonschema/jsonschema-valid.yml --schemafile ./docs/values.schema.json
- name: test invalid schema
run: |
AJV_PARAMS='--spec draft7 --allow-union-types --strict=false --all-errors --errors=json --validate-formats=false -r "plugins/**/*.schema.json" -r "./external-schemas/**.json"'
echo "jsonschema-invalid.yaml should have 23 errors"
cat .github/jsonschema/jsonschema-invalid.yml | yq -o=json > jsonschema-invalid.json
npx ajv-cli validate -s ./docs/values.schema.json $AJV_PARAMS -d jsonschema-invalid.json 2>&1 | tail --lines=+2 > invalid-result.json
cat invalid-result.json | jq -e "length == 10"
check-jsonschema .github/jsonschema/jsonschema-invalid.yml --schemafile ./docs/values.schema.json
10 changes: 9 additions & 1 deletion docs/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"description": "Kontinuous chart to use",
"type": "string",
"default": "app",
"anyOf": [
"oneOf": [
{
"const": "app",
"markdownDescription": "The [app chart](https://github.com/SocialGouv/kontinuous/blob/master/plugins/contrib/charts/app) provides all the resources to deploy a kubernetes application\n\n💡 You can use the [meta `~tpl~` prefix](https://socialgouv.github.io/kontinuous/#/./advanced/build?id=meta-values-plugin-tpl) to make any property a [go template](https://docs.gofiber.io/template/html/TEMPLATES_CHEATSHEET/#template-variables)"
Expand Down Expand Up @@ -211,6 +211,14 @@
{
"const": "redis",
"markdownDescription": "The [redis chart](https://github.com/SocialGouv/kontinuous/blob/master/plugins/contrib/charts/redis) deploys an [redis](https://oauth2-proxy.github.io/redis/) instance"
},
{
"const": "jobs",
"markdownDescription": "The [jobs chart](https://github.com/SocialGouv/kontinuous/blob/master/plugins/contrib/charts/jobs) provides a way to define de define tasks in your deployment pipeline\n\n💡 See [the jobs documentations](https://socialgouv.github.io/kontinuous/#/./advanced/build?id=meta-values-plugin-needs)."
},
{
"type": "string",
"markdownDescription": "Bring your own helm chart. \n\nYou should have an entry with the same name in your `./Chart.yaml`.\n\nSee https://socialgouv.github.io/kontinuous/#/./faq?id=add-a-custom-helm-chart"
}
]
},
Expand Down

0 comments on commit 242b9d1

Please sign in to comment.