From 99bc1a690782b10ff67f0887d5dcdd103c23dc9f Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Sun, 8 Sep 2024 18:37:05 +0200 Subject: [PATCH] fix: Add example to e2e tests --- examples/values.schema.json | 110 ++++++++++++++++++++++-------------- tests/run.sh | 3 + 2 files changed, 71 insertions(+), 42 deletions(-) diff --git a/examples/values.schema.json b/examples/values.schema.json index 575166c..24d903c 100644 --- a/examples/values.schema.json +++ b/examples/values.schema.json @@ -1,7 +1,10 @@ { + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false, "properties": { "global": { "description": "Global values are values that can be accessed from any chart or subchart by exactly the same name.", + "required": [], "title": "global", "type": "object" }, @@ -9,142 +12,165 @@ "additionalProperties": true, "properties": { "conf": { + "additionalProperties": false, + "examples": [ + "API_PROVIDER_ONE: api-key-x", + "EMAIL_ADMIN: admin@example.org" + ], "patternProperties": { "^API_.*": { "pattern": "^api-key", + "required": [], "type": "string" }, "^EMAIL_.*": { "format": "idn-email", + "required": [], "type": "string" } }, + "required": [], "title": "conf", - "type": "object", - "examples": [ - "API_PROVIDER_ONE: api-key-x", - "EMAIL_ADMIN: admin@example.org" - ] + "type": "object" }, "contact": { "default": "", - "format": "idn-email", - "title": "contact", "examples": [ "name@domain.tld" - ] + ], + "format": "idn-email", + "required": [], + "title": "contact" }, "enabled": { - "default": "true", + "default": true, "description": "Type will be parsed as boolean", + "required": [], "title": "enabled", "type": "boolean" }, "env": { + "additionalProperties": false, + "description": "Environment variables. If you want to provide auto-completion to the user ", "properties": { "ADMIN_EMAIL": { - "format": "idn-email", - "title": "ADMIN_EMAIL", - "type": "string", "examples": [ "admin@example.org" - ] + ], + "format": "idn-email", + "required": [], + "title": "ADMIN_EMAIL", + "type": "string" }, "API_URL": { - "format": "idn-hostname", - "title": "API_URL", - "type": "string", "examples": [ "https://api.example.org" - ] + ], + "format": "idn-hostname", + "required": [], + "title": "API_URL", + "type": "string" }, "CONFIG_PATH": { "description": "The local path to the service configuration file", - "title": "CONFIG_PATH", - "type": "string", "examples": [ "/path/to/config" - ] + ], + "required": [], + "title": "CONFIG_PATH", + "type": "string" } }, - "description": "Environment variables. If you want to provide auto-completion to the user ", - "title": "env", - "type": "object" + "required": [], + "title": "env" }, "hosts": { + "description": "Will give auto-completion for the below structure \nhosts: \n - name:\n url: my.example.org", "items": { "properties": { "host": { "properties": { "url": { "format": "idn-hostname", + "required": [], "type": "string" } }, + "required": [], "type": "object" } }, + "required": [], "type": "object" }, - "description": "Will give auto-completion for the below structure \nhosts: \n - name:\n url: my.example.org", + "required": [], "title": "hosts", "type": "array" }, "maintainer": { - "default": "maintainer@example.org", "const": "maintainer@example.org", + "default": "maintainer@example.org", + "required": [], "title": "maintainer" }, "name": { - "default": "", - "description": "Name of the deployed service. Defined in the schema annotation", - "title": "name", "anyOf": [ - {}, { - "pattern": "^foo-" + "required": [] + }, + { + "pattern": "^foo-", + "required": [] } - ] + ], + "default": "", + "description": "Name of the deployed service. Defined in the schema annotation", + "required": [], + "title": "name" }, "port": { - "default": "80", - "minimum": 80, + "default": 80, "maximum": 89, + "minimum": 80, + "required": [], "title": "port", "type": "integer" }, "storage": { "default": "10Gib", - "pattern": "^[1-9][0-9]*Gib$", - "title": "storage", - "type": "string", "examples": [ "5Gib", "10Gib", "20Gib" - ] + ], + "pattern": "^[1-9][0-9]*Gib$", + "required": [], + "title": "storage", + "type": "string" }, "telemetry": { "default": true, + "required": [], "title": "telemetry", "type": "boolean" }, "type": { "default": "application", - "title": "type", "enum": [ "application", "controller", "api" - ] + ], + "required": [], + "title": "type" } }, - "title": "service", "required": [ "enabled" - ] + ], + "title": "service" } }, - "$schema": "http://json-schema.org/draft-07/schema#", + "required": [], "type": "object" } \ No newline at end of file diff --git a/tests/run.sh b/tests/run.sh index 4df7715..c202344 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -2,6 +2,9 @@ rc=0 +cp ../examples/values.yaml test_repo_example.yaml +cp ../examples/values.schema.json test_repo_example_expected.schema.json + for test_file in test_*.yaml; do expected_file="${test_file%.yaml}_expected.schema.json" generated_file="${test_file%.yaml}_generated.schema.json"