Skip to content

Commit

Permalink
Improve readability of context schema (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Kuziemko authored Apr 8, 2022
1 parent b44676a commit 9d655f4
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 42 deletions.
6 changes: 2 additions & 4 deletions manifests/implementation/helm/storage/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ spec:
value:
url: "<@ releaseSvcUrl @>"
acceptValue: false
contextSchema: |-
{
contextSchema: {
"\$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"required": [
Expand Down Expand Up @@ -221,8 +220,7 @@ spec:
value:
url: "<@ templateSvcUrl @>"
acceptValue: false
contextSchema: |-
{
contextSchema: {
"\$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"required": [
Expand Down
47 changes: 32 additions & 15 deletions manifests/type/capactio/capact/validation/storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
75 changes: 54 additions & 21 deletions manifests/type/helm/release/storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
46 changes: 44 additions & 2 deletions manifests/type/helm/template/storage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 9d655f4

Please sign in to comment.