From 8040e58579781b9cc1b43559c74f1cc184354023 Mon Sep 17 00:00:00 2001 From: Thomas DA ROCHA Date: Sun, 29 Dec 2024 03:05:35 +0100 Subject: [PATCH] fix: Dofigen JSON Schema (#4312) Co-authored-by: Edwin Kofler --- CONTRIBUTING.md | 11 +- src/schema-validation.jsonc | 1 + src/schemas/json/dofigen.json | 801 ++++++++++++++--------------- src/test/dofigen/test.dofigen.yaml | 14 + 4 files changed, 423 insertions(+), 404 deletions(-) create mode 100644 src/test/dofigen/test.dofigen.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37e40dd3844..1f4a591d653 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -437,7 +437,16 @@ M src/test/prettierrc/.prettierrc.yml M src/test/prettierrc/prettierrc.json ``` -_Do not_ add those two files; pre-commit.ci seems to have issue with them. (Undo modifications to those files by unstaging them and running `git restore -- 'src/test/prettierrc/*'`) +_Do not_ add those two files; pre-commit.ci seems to have issue with them. (Undo modifications to those files by running `git restore -- 'src/test/prettierrc/*'`) + +To run Prettier on scpecific files, run: + +```console +# Run on a schema file +./node_modules/.bin/prettier --config .prettierrc.cjs --ignore-path .gitignore --write src/schemas/json/ +# Run on test files +./node_modules/.bin/prettier --config .prettierrc.cjs --ignore-path .gitignore --write src/test// +``` ## How-to diff --git a/src/schema-validation.jsonc b/src/schema-validation.jsonc index 0f173ba88dc..40e86c78aba 100644 --- a/src/schema-validation.jsonc +++ b/src/schema-validation.jsonc @@ -67,6 +67,7 @@ "devinit.schema-4.0.json", "devinit.schema-5.0.json", "devinit.schema-6.0.json", + "dofigen.json", "dotnetcli.host.json", "drone.json", "drupal-recipe.json", diff --git a/src/schemas/json/dofigen.json b/src/schemas/json/dofigen.json index 599cadcf5b0..481c2737a41 100644 --- a/src/schemas/json/dofigen.json +++ b/src/schemas/json/dofigen.json @@ -3,197 +3,171 @@ "$id": "https://json.schemastore.org/dofigen.json", "title": "Dofigen", "description": "Dofigen is a Dockerfile generator using a simplified description in YAML or JSON format", - "type": "object", - "oneOf": [ + "anyOf": [ { - "type": "object", - "required": ["fromImage"], - "properties": { - "fromImage": { - "$ref": "#/definitions/ParsableStruct" - } - } - }, - { - "type": "object", - "required": ["fromBuilder"], - "properties": { - "fromBuilder": { - "type": "string" - } - } + "$ref": "#/definitions/FromContext" }, { "type": "object", - "required": ["fromContext"], "properties": { - "fromContext": { - "type": ["string", "null"] - } - } - } - ], - "properties": { - "arg": { - "anyOf": [ - { - "$ref": "#/definitions/HashMapPatch" + "arg": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "bind": { - "anyOf": [ - { - "$ref": "#/definitions/VecDeepPatch>" + "bind": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "builders": { - "anyOf": [ - { - "$ref": "#/definitions/HashMapDeepPatch" + "builders": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapDeepPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "cache": { - "anyOf": [ - { - "$ref": "#/definitions/VecDeepPatch>" + "cache": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "cmd": { - "anyOf": [ - { - "$ref": "#/definitions/VecPatch" + "cmd": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "context": { - "anyOf": [ - { - "$ref": "#/definitions/VecPatch" + "context": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "copy": { - "anyOf": [ - { - "$ref": "#/definitions/VecDeepPatch>" + "copy": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "entrypoint": { - "anyOf": [ - { - "$ref": "#/definitions/VecPatch" + "entrypoint": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "env": { - "anyOf": [ - { - "$ref": "#/definitions/HashMapPatch" + "env": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "expose": { - "anyOf": [ - { - "$ref": "#/definitions/VecDeepPatch>" + "expose": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "extend": { - "$ref": "#/definitions/OneOrMany" - }, - "healthcheck": { - "anyOf": [ - { + "extend": { + "$ref": "#/definitions/OneOrMany" + }, + "healthcheck": { "anyOf": [ { - "$ref": "#/definitions/Healthcheck" + "anyOf": [ + { + "$ref": "#/definitions/Healthcheck" + }, + { + "type": "null" + } + ] }, { "type": "null" } ] }, - { - "type": "null" - } - ] - }, - "ignore": { - "anyOf": [ - { - "$ref": "#/definitions/VecPatch" + "ignore": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "root": { - "anyOf": [ - { + "root": { "anyOf": [ { - "$ref": "#/definitions/Run" + "anyOf": [ + { + "$ref": "#/definitions/Run" + }, + { + "type": "null" + } + ] }, { "type": "null" } ] }, - { - "type": "null" - } - ] - }, - "run": { - "anyOf": [ - { - "$ref": "#/definitions/VecPatch" + "run": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "user": { - "anyOf": [ - { + "user": { "anyOf": [ { "$ref": "#/definitions/ParsableStruct" @@ -203,16 +177,13 @@ } ] }, - { - "type": "null" + "workdir": { + "default": null, + "type": ["string", "null"] } - ] - }, - "workdir": { - "default": null, - "type": ["string", "null"] + } } - }, + ], "definitions": { "Add": { "title": "Add", @@ -224,7 +195,7 @@ }, "chmod": { "default": null, - "type": ["string", "null"] + "type": ["string", "number", "null"] }, "chown": { "anyOf": [ @@ -269,7 +240,7 @@ "properties": { "chmod": { "default": null, - "type": ["string", "null"] + "type": ["string", "number", "null"] }, "chown": { "anyOf": [ @@ -288,6 +259,16 @@ } ] }, + "exclude": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, "keepGitDir": { "default": null, "type": ["boolean", "null"] @@ -308,140 +289,96 @@ }, "Bind": { "title": "Bind", - "type": "object", - "oneOf": [ + "anyOf": [ { - "type": "object", - "required": ["fromImage"], - "properties": { - "fromImage": { - "$ref": "#/definitions/ParsableStruct" - } - } + "$ref": "#/definitions/FromContext" }, { "type": "object", - "required": ["fromBuilder"], "properties": { - "fromBuilder": { - "type": "string" - } - } - }, - { - "type": "object", - "required": ["fromContext"], - "properties": { - "fromContext": { + "readwrite": { + "default": null, + "type": ["boolean", "null"] + }, + "source": { + "default": null, + "type": ["string", "null"] + }, + "target": { + "default": null, "type": ["string", "null"] } } } - ], - "properties": { - "readwrite": { - "default": null, - "type": ["boolean", "null"] - }, - "source": { - "default": null, - "type": ["string", "null"] - }, - "target": { - "default": null, - "type": ["string", "null"] - } - } + ] }, "Cache": { "title": "Cache", - "type": "object", - "oneOf": [ - { - "type": "object", - "required": ["fromImage"], - "properties": { - "fromImage": { - "$ref": "#/definitions/ParsableStruct" - } - } - }, + "anyOf": [ { - "type": "object", - "required": ["fromBuilder"], - "properties": { - "fromBuilder": { - "type": "string" - } - } + "$ref": "#/definitions/FromContext" }, { "type": "object", - "required": ["fromContext"], "properties": { - "fromContext": { - "type": ["string", "null"] - } - } - } - ], - "properties": { - "chmod": { - "default": null, - "type": ["string", "null"] - }, - "chown": { - "anyOf": [ - { + "chmod": { + "default": null, + "type": ["string", "number", "null"] + }, + "chown": { "anyOf": [ { - "$ref": "#/definitions/User" + "anyOf": [ + { + "$ref": "#/definitions/User" + }, + { + "type": "null" + } + ] }, { "type": "null" } ] }, - { - "type": "null" - } - ] - }, - "id": { - "default": null, - "type": ["string", "null"] - }, - "readonly": { - "default": null, - "type": ["boolean", "null"] - }, - "sharing": { - "default": null, - "anyOf": [ - { + "id": { + "default": null, + "type": ["string", "null"] + }, + "readonly": { + "default": null, + "type": ["boolean", "null"] + }, + "sharing": { + "default": null, "anyOf": [ { - "$ref": "#/definitions/CacheSharing" + "anyOf": [ + { + "$ref": "#/definitions/CacheSharing" + }, + { + "type": "null" + } + ] }, { "type": "null" } ] }, - { - "type": "null" + "source": { + "default": null, + "type": ["string", "null"] + }, + "target": { + "default": null, + "type": ["string", "null"] } - ] - }, - "source": { - "default": null, - "type": ["string", "null"] - }, - "target": { - "default": null, - "type": ["string", "null"] + } } - } + ] }, "CacheSharing": { "description": "Represents a cache sharing strategy", @@ -450,40 +387,77 @@ }, "Copy": { "title": "Copy", - "type": "object", - "oneOf": [ - { - "type": "object", - "required": ["fromImage"], - "properties": { - "fromImage": { - "$ref": "#/definitions/ParsableStruct" - } - } - }, + "anyOf": [ { - "type": "object", - "required": ["fromBuilder"], - "properties": { - "fromBuilder": { - "type": "string" - } - } + "$ref": "#/definitions/FromContext" }, { "type": "object", - "required": ["fromContext"], "properties": { - "fromContext": { + "chmod": { + "default": null, + "type": ["string", "number", "null"] + }, + "chown": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/User" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "exclude": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "link": { + "default": null, + "type": ["boolean", "null"] + }, + "parents": { + "default": null, + "type": ["boolean", "null"] + }, + "paths": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "target": { + "default": null, "type": ["string", "null"] } } } - ], + ] + }, + "CopyContent": { + "title": "CopyContent", + "type": "object", "properties": { "chmod": { "default": null, - "type": ["string", "null"] + "type": ["string", "number", "null"] }, "chown": { "anyOf": [ @@ -502,19 +476,17 @@ } ] }, + "content": { + "default": null, + "type": ["string", "null"] + }, "link": { "default": null, "type": ["boolean", "null"] }, - "paths": { - "anyOf": [ - { - "$ref": "#/definitions/VecPatch" - }, - { - "type": "null" - } - ] + "substitute": { + "default": null, + "type": ["boolean", "null"] }, "target": { "default": null, @@ -527,6 +499,9 @@ { "$ref": "#/definitions/Copy" }, + { + "$ref": "#/definitions/CopyContent" + }, { "$ref": "#/definitions/AddGitRepo" }, @@ -578,7 +553,7 @@ "retries": { "default": null, "type": ["integer", "null"], - "minimum": 0 + "minimum": 0.0 }, "start": { "default": null, @@ -626,7 +601,7 @@ "port": { "default": null, "type": ["integer", "null"], - "minimum": 0 + "minimum": 0.0 } } }, @@ -717,7 +692,7 @@ "port": { "default": null, "type": ["integer", "null"], - "minimum": 0 + "minimum": 0.0 }, "protocol": { "default": null, @@ -794,136 +769,114 @@ }, "Stage": { "title": "Stage", - "type": "object", - "oneOf": [ - { - "type": "object", - "required": ["fromImage"], - "properties": { - "fromImage": { - "$ref": "#/definitions/ParsableStruct" - } - } - }, + "anyOf": [ { - "type": "object", - "required": ["fromBuilder"], - "properties": { - "fromBuilder": { - "type": "string" - } - } + "$ref": "#/definitions/FromContext" }, { "type": "object", - "required": ["fromContext"], "properties": { - "fromContext": { - "type": ["string", "null"] - } - } - } - ], - "properties": { - "arg": { - "anyOf": [ - { - "$ref": "#/definitions/HashMapPatch" + "arg": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "bind": { - "anyOf": [ - { - "$ref": "#/definitions/VecDeepPatch>" + "bind": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "cache": { - "anyOf": [ - { - "$ref": "#/definitions/VecDeepPatch>" + "cache": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "copy": { - "anyOf": [ - { - "$ref": "#/definitions/VecDeepPatch>" + "copy": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "env": { - "anyOf": [ - { - "$ref": "#/definitions/HashMapPatch" + "env": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "root": { - "anyOf": [ - { + "root": { "anyOf": [ { - "$ref": "#/definitions/Run" + "anyOf": [ + { + "$ref": "#/definitions/Run" + }, + { + "type": "null" + } + ] }, { "type": "null" } ] }, - { - "type": "null" - } - ] - }, - "run": { - "anyOf": [ - { - "$ref": "#/definitions/VecPatch" + "run": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] }, - { - "type": "null" - } - ] - }, - "user": { - "anyOf": [ - { + "user": { "anyOf": [ { - "$ref": "#/definitions/ParsableStruct" + "anyOf": [ + { + "$ref": "#/definitions/ParsableStruct" + }, + { + "type": "null" + } + ] }, { "type": "null" } ] }, - { - "type": "null" + "workdir": { + "default": null, + "type": ["string", "null"] } - ] - }, - "workdir": { - "default": null, - "type": ["string", "null"] + } } - } + ] }, "UnknownPatch": { "title": "CopyOptions", @@ -931,7 +884,7 @@ "properties": { "chmod": { "default": null, - "type": ["string", "null"] + "type": ["string", "number", "null"] }, "chown": { "anyOf": [ @@ -950,6 +903,16 @@ } ] }, + "exclude": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, "link": { "default": null, "type": ["boolean", "null"] @@ -1216,6 +1179,38 @@ } ] }, + "FromContext": { + "title": "FromContext", + "oneOf": [ + { + "type": "object", + "required": ["fromImage"], + "properties": { + "fromImage": { + "$ref": "#/definitions/ParsableStruct" + } + } + }, + { + "type": "object", + "required": ["fromBuilder"], + "properties": { + "fromBuilder": { + "type": "string" + } + } + }, + { + "type": "object", + "required": ["fromContext"], + "properties": { + "fromContext": { + "type": ["string", "null"] + } + } + } + ] + }, "VecPatch": { "title": "VecPatch", "oneOf": [ diff --git a/src/test/dofigen/test.dofigen.yaml b/src/test/dofigen/test.dofigen.yaml new file mode 100644 index 00000000000..160e475d3ba --- /dev/null +++ b/src/test/dofigen/test.dofigen.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=../../schemas/json/dofigen.json +# Runtime +workdir: /app +# volume: /app +arg: + TARGETPLATFORM: '' +copy: + - paths: builds/${TARGETPLATFORM}/dofigen + target: /bin/dofigen + chmod: 555 +entrypoint: /bin/dofigen +cmd: --help +context: + - '/builds'