From 9d655f475b7bf67c4dd7d4e6944fbea4a84b01bd Mon Sep 17 00:00:00 2001 From: Mateusz Kuziemko Date: Fri, 8 Apr 2022 07:44:03 +0200 Subject: [PATCH] Improve readability of context schema (#65) --- .../implementation/helm/storage/install.yaml | 6 +- .../capactio/capact/validation/storage.yaml | 47 ++++++++---- manifests/type/helm/release/storage.yaml | 75 +++++++++++++------ manifests/type/helm/template/storage.yaml | 46 +++++++++++- 4 files changed, 132 insertions(+), 42 deletions(-) diff --git a/manifests/implementation/helm/storage/install.yaml b/manifests/implementation/helm/storage/install.yaml index 3c25601e..002cce3f 100644 --- a/manifests/implementation/helm/storage/install.yaml +++ b/manifests/implementation/helm/storage/install.yaml @@ -180,8 +180,7 @@ spec: value: url: "<@ releaseSvcUrl @>" acceptValue: false - contextSchema: |- - { + contextSchema: { "\$schema": "http://json-schema.org/draft-07/schema", "type": "object", "required": [ @@ -221,8 +220,7 @@ spec: value: url: "<@ templateSvcUrl @>" acceptValue: false - contextSchema: |- - { + contextSchema: { "\$schema": "http://json-schema.org/draft-07/schema", "type": "object", "required": [ diff --git a/manifests/type/capactio/capact/validation/storage.yaml b/manifests/type/capactio/capact/validation/storage.yaml index c3d443cb..d7c1b9d1 100644 --- a/manifests/type/capactio/capact/validation/storage.yaml +++ b/manifests/type/capactio/capact/validation/storage.yaml @@ -26,21 +26,38 @@ spec: "acceptValue", "contextSchema" ], - "properties": { - "url": { - "$id": "#/properties/url", - "type": "string", - "format": "uri" - }, - "contextSchema": { - "$id": "#/properties/contextSchema", - "const": "\n\t{\n \"$schema\": \"http://json-schema.org/draft-07/schema\",\n \"type\": \"object\",\n \"required\": [\n \"provider\"\n ],\n \"properties\": {\n \"provider\": {\n \"$id\": \"#/properties/context/properties/provider\",\n \"type\": \"string\",\n \"enum\": [\n \"aws_secretsmanager\",\n \"dotenv\"\n ]\n }\n },\n \"additionalProperties\": false\n }\n" - }, - "acceptValue": { - "$id": "#/properties/acceptValue", - "type": "boolean", - "const": true - } + "properties":{ + "url":{ + "$id": "#/properties/url", + "type": "string", + "format": "uri" + }, + "contextSchema":{ + "$id": "#/properties/contextSchema", + "const":{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "required":[ + "provider" + ], + "properties":{ + "provider":{ + "$id": "#/properties/context/properties/provider", + "type": "string", + "enum":[ + "aws_secretsmanager", + "dotenv" + ] + } + }, + "additionalProperties": false + } + }, + "acceptValue":{ + "$id": "#/properties/acceptValue", + "type": "boolean", + "const": true + } }, "additionalProperties": false } diff --git a/manifests/type/helm/release/storage.yaml b/manifests/type/helm/release/storage.yaml index 4c9d3818..f90db316 100644 --- a/manifests/type/helm/release/storage.yaml +++ b/manifests/type/helm/release/storage.yaml @@ -19,28 +19,61 @@ spec: jsonSchema: value: |- { - "$schema": "http://json-schema.org/draft-07/schema", - "type": "object", - "title": "The root schema", - "required": [ - "url", - "contextSchema", - "acceptValue" - ], - "properties": { - "url": { - "$id": "#/properties/url", + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "title": "The root schema", + "required": [ + "url", + "contextSchema", + "acceptValue" + ], + "properties": { + "url": { + "$id": "#/properties/url", + "type": "string", + "format": "uri" + }, + "contextSchema": { + "const":{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "required": [ + "name", + "namespace", + "chartLocation" + ], + "properties": { + "name": { + "$id": "#/properties/context/properties/name", + "type": "string" + }, + "namespace": { + "$id": "#/properties/context/properties/namespace", + "type": "string" + }, + "chartLocation": { + "$id": "#/properties/context/properties/chartLocation", + "type": "string" + }, + "driver": { + "$id": "#/properties/context/properties/driver", "type": "string", - "format": "uri" - }, - "contextSchema": { - "const": "{\n \"$schema\": \"http://json-schema.org/draft-07/schema\",\n \"type\": \"object\",\n \"required\": [\n \"name\",\n \"namespace\",\n \"chartLocation\"\n ],\n \"properties\": {\n \"name\": {\n \"$id\": \"#/properties/context/properties/name\",\n \"type\": \"string\"\n },\n \"namespace\": {\n \"$id\": \"#/properties/context/properties/namespace\",\n \"type\": \"string\"\n },\n \"chartLocation\": {\n \"$id\": \"#/properties/context/properties/chartLocation\",\n \"type\": \"string\"\n },\n \"driver\": {\n \"$id\": \"#/properties/context/properties/driver\",\n \"type\": \"string\",\n \"default\": \"secrets\",\n \"enum\": [\n \"secrets\",\n \"configmaps\",\n \"sql\"\n ]\n }\n },\n \"additionalProperties\": false\n}" + "default": "secrets", + "enum": [ + "secrets", + "configmaps", + "sql" + ] + } }, - "acceptValue": { - "$id": "#/properties/acceptValue", - "type": "boolean", - "const": false - } + "additionalProperties": false + } }, - "additionalProperties": false + "acceptValue": { + "$id": "#/properties/acceptValue", + "type": "boolean", + "const": false + } + }, + "additionalProperties": false } diff --git a/manifests/type/helm/template/storage.yaml b/manifests/type/helm/template/storage.yaml index f36d5840..e046a58e 100644 --- a/manifests/type/helm/template/storage.yaml +++ b/manifests/type/helm/template/storage.yaml @@ -17,7 +17,6 @@ spec: additionalRefs: - cap.core.type.hub.storage jsonSchema: - # TODO: Change globally `contextSchema` to object value: |- { "$schema": "http://json-schema.org/draft-07/schema", @@ -35,7 +34,50 @@ spec: "format": "uri" }, "contextSchema": { - "const": "{\n \"$schema\": \"http://json-schema.org/draft-07/schema\",\n \"type\": \"object\",\n \"required\": [\n \"goTemplate\",\n \"release\"\n ],\n \"properties\": {\n \"goTemplate\": {\n \"$id\": \"#/properties/context/properties/goTemplate\",\n \"type\": \"string\"\n },\n \"release\": {\n \"required\": [\n \"name\",\n \"namespace\"\n ],\n \"$id\": \"#/properties/context/properties/release\",\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"properties\": {\n \"name\": {\n \"$id\": \"#/properties/context/properties/release/properties/name\",\n \"type\": \"string\"\n },\n \"namespace\": {\n \"$id\": \"#/properties/context/properties/release/properties/namespace\",\n \"type\": \"string\"\n },\n \"driver\": {\n \"$id\": \"#/properties/context/properties/release/properties/driver\",\n \"type\": \"string\",\n \"default\": \"secrets\",\n \"enum\": [\n \"secrets\",\n \"configmaps\",\n \"sql\"\n ]\n }\n }\n }\n },\n \"additionalProperties\": false\n}" + "const": { + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "required": [ + "goTemplate", + "release" + ], + "properties": { + "goTemplate": { + "$id": "#/properties/context/properties/goTemplate", + "type": "string" + }, + "release": { + "required": [ + "name", + "namespace" + ], + "$id": "#/properties/context/properties/release", + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "$id": "#/properties/context/properties/release/properties/name", + "type": "string" + }, + "namespace": { + "$id": "#/properties/context/properties/release/properties/namespace", + "type": "string" + }, + "driver": { + "$id": "#/properties/context/properties/release/properties/driver", + "type": "string", + "default": "secrets", + "enum": [ + "secrets", + "configmaps", + "sql" + ] + } + } + } + }, + "additionalProperties": false + } }, "acceptValue": { "$id": "#/properties/acceptValue",