From 7f319e8fa9443946dfd23d4df28223bae86661c9 Mon Sep 17 00:00:00 2001 From: Thomas DA ROCHA Date: Fri, 20 Dec 2024 17:14:15 +0100 Subject: [PATCH] feat: Add Dofigen JSON Schema --- src/api/json/catalog.json | 13 + src/schemas/json/dofigen.json | 1433 +++++++++++++++++ .../springboot-maven.base.permissive.yml | 22 + .../springboot-maven.override.permissive.yml | 7 + 4 files changed, 1475 insertions(+) create mode 100644 src/schemas/json/dofigen.json create mode 100644 src/test/dofigen/springboot-maven.base.permissive.yml create mode 100644 src/test/dofigen/springboot-maven.override.permissive.yml diff --git a/src/api/json/catalog.json b/src/api/json/catalog.json index 2e1d1248aef..790de75a975 100644 --- a/src/api/json/catalog.json +++ b/src/api/json/catalog.json @@ -1814,6 +1814,19 @@ "fileMatch": ["docfx.json"], "url": "https://json.schemastore.org/docfx.json" }, + { + "name": "Dofigen", + "description": "Dofigen configuration file. Documentation: https://github.com/lenra-io/dofigen", + "fileMatch": [ + "dofigen.yaml", + "dofigen.json", + "dofigen.yml", + "*.dofigen.yaml", + "*.dofigen.json", + "*.dofigen.yml" + ], + "url": "https://json.schemastore.org/dofigen.json" + }, { "name": "Dolittle Artifacts", "description": "A Dolittle bounded context's artifacts", diff --git a/src/schemas/json/dofigen.json b/src/schemas/json/dofigen.json new file mode 100644 index 00000000000..122b615ffb3 --- /dev/null +++ b/src/schemas/json/dofigen.json @@ -0,0 +1,1433 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$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": [ + { + "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" + ] + } + } + } + ], + "properties": { + "arg": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapPatch" + }, + { + "type": "null" + } + ] + }, + "bind": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] + }, + "builders": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapDeepPatch" + }, + { + "type": "null" + } + ] + }, + "cache": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] + }, + "cmd": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "context": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "copy": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] + }, + "entrypoint": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "env": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapPatch" + }, + { + "type": "null" + } + ] + }, + "expose": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] + }, + "extend": { + "$ref": "#/definitions/OneOrMany" + }, + "healthcheck": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/Healthcheck" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "ignore": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "root": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/Run" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "run": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "user": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/ParsableStruct" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "workdir": { + "default": null, + "type": [ + "string", + "null" + ] + } + }, + "definitions": { + "Add": { + "title": "Add", + "type": "object", + "properties": { + "checksum": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "chmod": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "chown": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/User" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "files": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "link": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "target": { + "default": null, + "type": [ + "string", + "null" + ] + } + } + }, + "AddGitRepo": { + "title": "AddGitRepo", + "type": "object", + "properties": { + "chmod": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "chown": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/User" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "keepGitDir": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "link": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "repo": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "target": { + "default": null, + "type": [ + "string", + "null" + ] + } + } + }, + "Bind": { + "title": "Bind", + "type": "object", + "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" + ] + } + } + } + ], + "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" + } + } + }, + { + "type": "object", + "required": [ + "fromBuilder" + ], + "properties": { + "fromBuilder": { + "type": "string" + } + } + }, + { + "type": "object", + "required": [ + "fromContext" + ], + "properties": { + "fromContext": { + "type": [ + "string", + "null" + ] + } + } + } + ], + "properties": { + "chmod": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "chown": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/User" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "id": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "readonly": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "sharing": { + "default": null, + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/CacheSharing" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "source": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "target": { + "default": null, + "type": [ + "string", + "null" + ] + } + } + }, + "CacheSharing": { + "description": "Represents a cache sharing strategy", + "type": "string", + "enum": [ + "shared", + "private", + "locked" + ] + }, + "Copy": { + "title": "Copy", + "type": "object", + "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" + ] + } + } + } + ], + "properties": { + "chmod": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "chown": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/User" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "link": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "paths": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "target": { + "default": null, + "type": [ + "string", + "null" + ] + } + } + }, + "CopyResourcePatch": { + "anyOf": [ + { + "$ref": "#/definitions/Copy" + }, + { + "$ref": "#/definitions/AddGitRepo" + }, + { + "$ref": "#/definitions/Add" + }, + { + "$ref": "#/definitions/UnknownPatch" + } + ] + }, + "HashMapDeepPatch": { + "title": "HashMapDeepPatch", + "type": "object", + "patternProperties": { + "^.+$": { + "anyOf": [ + { + "$ref": "#/definitions/Stage" + }, + { + "type": "null" + } + ] + } + } + }, + "HashMapPatch": { + "title": "HashMapPatch", + "type": "object", + "patternProperties": { + "^.+$": { + "type": [ + "string", + "null" + ] + } + } + }, + "Healthcheck": { + "title": "Healthcheck", + "type": "object", + "properties": { + "cmd": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "interval": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "retries": { + "default": null, + "type": [ + "integer", + "null" + ], + "minimum": 0 + }, + "start": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "timeout": { + "default": null, + "type": [ + "string", + "null" + ] + } + } + }, + "ImageName": { + "title": "ImageName", + "description": "Represents a Docker image version", + "type": "object", + "oneOf": [ + { + "type": "object", + "required": [ + "tag" + ], + "properties": { + "tag": { + "type": "string" + } + } + }, + { + "type": "object", + "required": [ + "digest" + ], + "properties": { + "digest": { + "type": "string" + } + } + } + ], + "properties": { + "host": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "path": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "port": { + "default": null, + "type": [ + "integer", + "null" + ], + "minimum": 0 + } + } + }, + "OneOrMany": { + "title": "OneOrMany", + "oneOf": [ + { + "$ref": "#/definitions/Resource" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/Resource" + } + } + ] + }, + "ParsableStruct": { + "title": "ParsableStruct", + "oneOf": [ + { + "$ref": "#/definitions/Bind" + }, + { + "type": "string" + } + ] + }, + "ParsableStruct": { + "title": "ParsableStruct", + "oneOf": [ + { + "$ref": "#/definitions/Cache" + }, + { + "type": "string" + } + ] + }, + "ParsableStruct": { + "title": "ParsableStruct", + "oneOf": [ + { + "$ref": "#/definitions/CopyResourcePatch" + }, + { + "type": "string" + } + ] + }, + "ParsableStruct": { + "title": "ParsableStruct", + "oneOf": [ + { + "$ref": "#/definitions/ImageName" + }, + { + "type": "string" + } + ] + }, + "ParsableStruct": { + "title": "ParsableStruct", + "oneOf": [ + { + "$ref": "#/definitions/Port" + }, + { + "type": "string" + } + ] + }, + "ParsableStruct": { + "title": "ParsableStruct", + "oneOf": [ + { + "$ref": "#/definitions/User" + }, + { + "type": "string" + } + ] + }, + "Port": { + "title": "Port", + "type": "object", + "properties": { + "port": { + "default": null, + "type": [ + "integer", + "null" + ], + "minimum": 0 + }, + "protocol": { + "default": null, + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/PortProtocol" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + } + } + }, + "PortProtocol": { + "description": "Represents a port protocol", + "type": "string", + "enum": [ + "tcp", + "udp" + ] + }, + "Resource": { + "description": "Represents a resource", + "anyOf": [ + { + "type": "string", + "format": "uri" + }, + { + "type": "string" + } + ] + }, + "Run": { + "title": "Run", + "type": "object", + "properties": { + "bind": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] + }, + "cache": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] + }, + "run": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + } + } + }, + "Stage": { + "title": "Stage", + "type": "object", + "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" + ] + } + } + } + ], + "properties": { + "arg": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapPatch" + }, + { + "type": "null" + } + ] + }, + "bind": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] + }, + "cache": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] + }, + "copy": { + "anyOf": [ + { + "$ref": "#/definitions/VecDeepPatch>" + }, + { + "type": "null" + } + ] + }, + "env": { + "anyOf": [ + { + "$ref": "#/definitions/HashMapPatch" + }, + { + "type": "null" + } + ] + }, + "root": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/Run" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "run": { + "anyOf": [ + { + "$ref": "#/definitions/VecPatch" + }, + { + "type": "null" + } + ] + }, + "user": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/ParsableStruct" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "workdir": { + "default": null, + "type": [ + "string", + "null" + ] + } + } + }, + "UnknownPatch": { + "title": "CopyOptions", + "type": "object", + "properties": { + "chmod": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "chown": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/User" + }, + { + "type": "null" + } + ] + }, + { + "type": "null" + } + ] + }, + "link": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, + "target": { + "default": null, + "type": [ + "string", + "null" + ] + } + } + }, + "User": { + "title": "User", + "type": "object", + "properties": { + "group": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "user": { + "default": null, + "type": [ + "string", + "null" + ] + } + } + }, + "VecDeepPatch>": { + "title": "VecDeepPatch>", + "oneOf": [ + { + "$ref": "#/definitions/ParsableStruct" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + { + "type": "object", + "patternProperties": { + "^\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "^\\+\\d+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "^\\d+$": { + "$ref": "#/definitions/ParsableStruct" + }, + "^\\d+<$": { + "$ref": "#/definitions/ParsableStruct" + }, + "^\\d+\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "_": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + } + } + } + ] + }, + "VecDeepPatch>": { + "title": "VecDeepPatch>", + "oneOf": [ + { + "$ref": "#/definitions/ParsableStruct" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + { + "type": "object", + "patternProperties": { + "^\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "^\\+\\d+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "^\\d+$": { + "$ref": "#/definitions/ParsableStruct" + }, + "^\\d+<$": { + "$ref": "#/definitions/ParsableStruct" + }, + "^\\d+\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "_": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + } + } + } + ] + }, + "VecDeepPatch>": { + "title": "VecDeepPatch>", + "oneOf": [ + { + "$ref": "#/definitions/ParsableStruct" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + { + "type": "object", + "patternProperties": { + "^\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "^\\+\\d+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "^\\d+$": { + "$ref": "#/definitions/ParsableStruct" + }, + "^\\d+<$": { + "$ref": "#/definitions/ParsableStruct" + }, + "^\\d+\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "_": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + } + } + } + ] + }, + "VecDeepPatch>": { + "title": "VecDeepPatch>", + "oneOf": [ + { + "$ref": "#/definitions/ParsableStruct" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + { + "type": "object", + "patternProperties": { + "^\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "^\\+\\d+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "^\\d+$": { + "$ref": "#/definitions/ParsableStruct" + }, + "^\\d+<$": { + "$ref": "#/definitions/ParsableStruct" + }, + "^\\d+\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + }, + "_": { + "type": "array", + "items": { + "$ref": "#/definitions/ParsableStruct" + } + } + } + } + ] + }, + "VecPatch": { + "title": "VecPatch", + "oneOf": [ + { + "$ref": "#/definitions/Resource" + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/Resource" + } + }, + { + "type": "object", + "patternProperties": { + "^\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/Resource" + } + }, + "^\\+\\d+$": { + "type": "array", + "items": { + "$ref": "#/definitions/Resource" + } + }, + "^\\d+$": { + "$ref": "#/definitions/Resource" + }, + "^\\d+\\+$": { + "type": "array", + "items": { + "$ref": "#/definitions/Resource" + } + }, + "_": { + "type": "array", + "items": { + "$ref": "#/definitions/Resource" + } + } + } + } + ] + }, + "VecPatch": { + "title": "VecPatch", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "object", + "patternProperties": { + "^\\+$": { + "type": "array", + "items": { + "type": "string" + } + }, + "^\\+\\d+$": { + "type": "array", + "items": { + "type": "string" + } + }, + "^\\d+$": { + "type": "string" + }, + "^\\d+\\+$": { + "type": "array", + "items": { + "type": "string" + } + }, + "_": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/dofigen/springboot-maven.base.permissive.yml b/src/test/dofigen/springboot-maven.base.permissive.yml new file mode 100644 index 00000000000..0a562fe0327 --- /dev/null +++ b/src/test/dofigen/springboot-maven.base.permissive.yml @@ -0,0 +1,22 @@ +builders: + maven-builder: + fromImage: maven:3.9-eclipse-temurin-17-alpine + workdir: /app + add: + - "." + root: + run: + - mvn package -DskipTests + - mv target/*.jar app.jar + cache: + - /root/.m2 + - /app/target +fromImage: eclipse-temurin:17-jre-alpine +artifacts: + - fromBuilder: maven-builder + source: /app/app.jar + target: app.jar +cmd: ["java","-jar","app.jar"] +context: + - /pom.xml + - /src/main/ \ No newline at end of file diff --git a/src/test/dofigen/springboot-maven.override.permissive.yml b/src/test/dofigen/springboot-maven.override.permissive.yml new file mode 100644 index 00000000000..f87a2cdb8c9 --- /dev/null +++ b/src/test/dofigen/springboot-maven.override.permissive.yml @@ -0,0 +1,7 @@ +extend: springboot-maven.base.permissive.yml +builders: + maven-builder: + fromImage: + tag: 3-eclipse-temurin-21-alpine +fromImage: + tag: 21-jre-alpine \ No newline at end of file