diff --git a/packages/go/model/model.go b/packages/go/model/model.go index 8c77984..f8284f6 100644 --- a/packages/go/model/model.go +++ b/packages/go/model/model.go @@ -387,21 +387,27 @@ type LanguageTarget struct { type LanguageTargetSpec struct { Icon *IconValue `json:"icon,omitempty"` - Local LocalDevContainer `json:"local"` + Local LocalDevContainer `json:"local"` // if type is "docker" or empty - Local development container using a fixed docker image.; User code will be mounted into the container.; if type is "dockerfile" - Local development container using a Dockerfile. User code will; be built into the container. Schema map[string]interface{} `json:"schema,omitempty"` Versioning []Versioning `json:"versioning,omitempty"` } +// if type is "docker" or empty - Local development container using a fixed docker image. +// User code will be mounted into the container. +// if type is "dockerfile" - Local development container using a Dockerfile. User code will +// be built into the container. type LocalDevContainer struct { Env []string `json:"Env,omitempty"` Handlers *LocalDevContainerHandlers `json:"handlers,omitempty"` Healthcheck *string `json:"healthcheck,omitempty"` HostConfig map[string]interface{} `json:"HostConfig,omitempty"` - Image string `json:"image"` + Image *string `json:"image,omitempty"` Labels map[string]interface{} `json:"Labels,omitempty"` Options map[string]interface{} `json:"options,omitempty"` + Type *string `json:"type,omitempty"` UserHome *string `json:"userHome,omitempty"` WorkingDir *string `json:"workingDir,omitempty"` + File *string `json:"file,omitempty"` } type LocalDevContainerHandlers struct { diff --git a/packages/go/schemas/concepts/core/language-target.json b/packages/go/schemas/concepts/core/language-target.json index a6ccb8e..0914b1d 100644 --- a/packages/go/schemas/concepts/core/language-target.json +++ b/packages/go/schemas/concepts/core/language-target.json @@ -7,6 +7,77 @@ "schema": { "$id": "/core/language-target", "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "LocalDevContainerDocker": { + "type": "object", + "additionalProperties": false, + "required": [ + "image" + ], + "properties": { + "type": { + "type": "string", + "const": "docker" + }, + "image": { + "type": "string" + }, + "options": { + "type": "object", + "additionalProperties": true + }, + "userHome": { + "type": "string" + }, + "workingDir": { + "type": "string" + }, + "healthcheck": { + "type": "string" + }, + "HostConfig": { + "type": "object", + "additionalProperties": true + }, + "Labels": { + "type": "object", + "additionalProperties": true + }, + "Env": { + "type": "array", + "items": { + "type": "string" + } + }, + "handlers": { + "title": "LocalDevContainerHandlers", + "type": "object", + "additionalProperties": false, + "properties": { + "onCreate": { + "type": "string" + } + } + } + } + }, + "LocalDevContainerDockerfile": { + "type": "object", + "additionalProperties": false, + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "const": "dockerfile" + }, + "file": { + "type": "string" + } + } + } + }, "type": "object", "additionalProperties": false, "required": [ @@ -40,53 +111,15 @@ }, "local": { "title": "LocalDevContainer", - "type": "object", - "additionalProperties": false, - "required": [ - "image" - ], - "properties": { - "image": { - "type": "string" - }, - "options": { - "type": "object", - "additionalProperties": true - }, - "userHome": { - "type": "string" - }, - "workingDir": { - "type": "string" + "description": "if type is \"docker\" or empty - Local development container using a fixed docker image. User code will be mounted into the container.\nif type is \"dockerfile\" - Local development container using a Dockerfile. User code will be built into the container.", + "oneOf": [ + { + "$ref": "#/definitions/LocalDevContainerDocker" }, - "healthcheck": { - "type": "string" - }, - "HostConfig": { - "type": "object", - "additionalProperties": true - }, - "Labels": { - "type": "object", - "additionalProperties": true - }, - "Env": { - "type": "array", - "items": { - "type": "string" - } - }, - "handlers": { - "title": "LocalDevContainerHandlers", - "type": "object", - "additionalProperties": false, - "properties": { - "onCreate": { - "type": "string" - } - } + { + "$ref": "#/definitions/LocalDevContainerDockerfile" } - } + ] } } } diff --git a/packages/maven/pom.xml b/packages/maven/pom.xml index 9fc8144..32d9ff9 100644 --- a/packages/maven/pom.xml +++ b/packages/maven/pom.xml @@ -6,7 +6,7 @@ com.kapeta schemas - 3.3.0 + 3.4.0 ${project.groupId}:${project.artifactId} Data schemas for Kapeta diff --git a/packages/maven/src/main/java/com/kapeta/schemas/entity/LocalDevContainer.java b/packages/maven/src/main/java/com/kapeta/schemas/entity/LocalDevContainer.java index 15ee095..a0e3831 100644 --- a/packages/maven/src/main/java/com/kapeta/schemas/entity/LocalDevContainer.java +++ b/packages/maven/src/main/java/com/kapeta/schemas/entity/LocalDevContainer.java @@ -3,6 +3,12 @@ import java.util.List; import java.util.Map; +/** + * if type is "docker" or empty - Local development container using a fixed docker image. + * User code will be mounted into the container. + * if type is "dockerfile" - Local development container using a Dockerfile. User code will + * be built into the container. + */ @lombok.Data public class LocalDevContainer { private List env; @@ -12,6 +18,8 @@ public class LocalDevContainer { private String image; private Map labels; private Map options; + private String type; private String userHome; private String workingDir; + private String file; } diff --git a/packages/maven/src/main/resources/schemas/concepts/core/language-target.json b/packages/maven/src/main/resources/schemas/concepts/core/language-target.json index a6ccb8e..0914b1d 100644 --- a/packages/maven/src/main/resources/schemas/concepts/core/language-target.json +++ b/packages/maven/src/main/resources/schemas/concepts/core/language-target.json @@ -7,6 +7,77 @@ "schema": { "$id": "/core/language-target", "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "LocalDevContainerDocker": { + "type": "object", + "additionalProperties": false, + "required": [ + "image" + ], + "properties": { + "type": { + "type": "string", + "const": "docker" + }, + "image": { + "type": "string" + }, + "options": { + "type": "object", + "additionalProperties": true + }, + "userHome": { + "type": "string" + }, + "workingDir": { + "type": "string" + }, + "healthcheck": { + "type": "string" + }, + "HostConfig": { + "type": "object", + "additionalProperties": true + }, + "Labels": { + "type": "object", + "additionalProperties": true + }, + "Env": { + "type": "array", + "items": { + "type": "string" + } + }, + "handlers": { + "title": "LocalDevContainerHandlers", + "type": "object", + "additionalProperties": false, + "properties": { + "onCreate": { + "type": "string" + } + } + } + } + }, + "LocalDevContainerDockerfile": { + "type": "object", + "additionalProperties": false, + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "const": "dockerfile" + }, + "file": { + "type": "string" + } + } + } + }, "type": "object", "additionalProperties": false, "required": [ @@ -40,53 +111,15 @@ }, "local": { "title": "LocalDevContainer", - "type": "object", - "additionalProperties": false, - "required": [ - "image" - ], - "properties": { - "image": { - "type": "string" - }, - "options": { - "type": "object", - "additionalProperties": true - }, - "userHome": { - "type": "string" - }, - "workingDir": { - "type": "string" + "description": "if type is \"docker\" or empty - Local development container using a fixed docker image. User code will be mounted into the container.\nif type is \"dockerfile\" - Local development container using a Dockerfile. User code will be built into the container.", + "oneOf": [ + { + "$ref": "#/definitions/LocalDevContainerDocker" }, - "healthcheck": { - "type": "string" - }, - "HostConfig": { - "type": "object", - "additionalProperties": true - }, - "Labels": { - "type": "object", - "additionalProperties": true - }, - "Env": { - "type": "array", - "items": { - "type": "string" - } - }, - "handlers": { - "title": "LocalDevContainerHandlers", - "type": "object", - "additionalProperties": false, - "properties": { - "onCreate": { - "type": "string" - } - } + { + "$ref": "#/definitions/LocalDevContainerDockerfile" } - } + ] } } } diff --git a/packages/npm/package.json b/packages/npm/package.json index 0265299..e9329a9 100644 --- a/packages/npm/package.json +++ b/packages/npm/package.json @@ -1,6 +1,6 @@ { "name": "@kapeta/schemas", - "version": "3.3.0", + "version": "3.4.0", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "types": "dist/index.d.ts", diff --git a/packages/npm/schemas/concepts/core/language-target.json b/packages/npm/schemas/concepts/core/language-target.json index a6ccb8e..0914b1d 100644 --- a/packages/npm/schemas/concepts/core/language-target.json +++ b/packages/npm/schemas/concepts/core/language-target.json @@ -7,6 +7,77 @@ "schema": { "$id": "/core/language-target", "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "LocalDevContainerDocker": { + "type": "object", + "additionalProperties": false, + "required": [ + "image" + ], + "properties": { + "type": { + "type": "string", + "const": "docker" + }, + "image": { + "type": "string" + }, + "options": { + "type": "object", + "additionalProperties": true + }, + "userHome": { + "type": "string" + }, + "workingDir": { + "type": "string" + }, + "healthcheck": { + "type": "string" + }, + "HostConfig": { + "type": "object", + "additionalProperties": true + }, + "Labels": { + "type": "object", + "additionalProperties": true + }, + "Env": { + "type": "array", + "items": { + "type": "string" + } + }, + "handlers": { + "title": "LocalDevContainerHandlers", + "type": "object", + "additionalProperties": false, + "properties": { + "onCreate": { + "type": "string" + } + } + } + } + }, + "LocalDevContainerDockerfile": { + "type": "object", + "additionalProperties": false, + "required": [ + "type" + ], + "properties": { + "type": { + "type": "string", + "const": "dockerfile" + }, + "file": { + "type": "string" + } + } + } + }, "type": "object", "additionalProperties": false, "required": [ @@ -40,53 +111,15 @@ }, "local": { "title": "LocalDevContainer", - "type": "object", - "additionalProperties": false, - "required": [ - "image" - ], - "properties": { - "image": { - "type": "string" - }, - "options": { - "type": "object", - "additionalProperties": true - }, - "userHome": { - "type": "string" - }, - "workingDir": { - "type": "string" + "description": "if type is \"docker\" or empty - Local development container using a fixed docker image. User code will be mounted into the container.\nif type is \"dockerfile\" - Local development container using a Dockerfile. User code will be built into the container.", + "oneOf": [ + { + "$ref": "#/definitions/LocalDevContainerDocker" }, - "healthcheck": { - "type": "string" - }, - "HostConfig": { - "type": "object", - "additionalProperties": true - }, - "Labels": { - "type": "object", - "additionalProperties": true - }, - "Env": { - "type": "array", - "items": { - "type": "string" - } - }, - "handlers": { - "title": "LocalDevContainerHandlers", - "type": "object", - "additionalProperties": false, - "properties": { - "onCreate": { - "type": "string" - } - } + { + "$ref": "#/definitions/LocalDevContainerDockerfile" } - } + ] } } } diff --git a/packages/npm/src/types/index.ts b/packages/npm/src/types/index.ts index 193cea4..91b311c 100644 --- a/packages/npm/src/types/index.ts +++ b/packages/npm/src/types/index.ts @@ -510,22 +510,36 @@ export interface LanguageTarget { } export interface LanguageTargetSpec { - icon?: IconValue; + icon?: IconValue; + /** + * if type is "docker" or empty - Local development container using a fixed docker image. + * User code will be mounted into the container. + * if type is "dockerfile" - Local development container using a Dockerfile. User code will + * be built into the container. + */ local: LocalDevContainer; schema?: { [key: string]: any }; versioning?: Versioning[]; } +/** + * if type is "docker" or empty - Local development container using a fixed docker image. + * User code will be mounted into the container. + * if type is "dockerfile" - Local development container using a Dockerfile. User code will + * be built into the container. + */ export interface LocalDevContainer { Env?: string[]; handlers?: LocalDevContainerHandlers; healthcheck?: string; HostConfig?: { [key: string]: any }; - image: string; + image?: string; Labels?: { [key: string]: any }; options?: { [key: string]: any }; + type?: string; userHome?: string; workingDir?: string; + file?: string; } export interface LocalDevContainerHandlers { diff --git a/schemas/concepts/language-target.yml b/schemas/concepts/language-target.yml index 58e2323..a478538 100644 --- a/schemas/concepts/language-target.yml +++ b/schemas/concepts/language-target.yml @@ -8,6 +8,56 @@ spec: schema: $id: /core/language-target $schema: http://json-schema.org/draft-07/schema# + definitions: + LocalDevContainerDocker: + type: object + additionalProperties: false + required: + - image + properties: + type: + type: string + const: docker + image: + type: string + options: + type: object + additionalProperties: true + userHome: + type: string + workingDir: + type: string + healthcheck: + type: string + HostConfig: + type: object + additionalProperties: true + Labels: + type: object + additionalProperties: true + Env: + type: array + items: + type: string + handlers: + title: LocalDevContainerHandlers + type: object + additionalProperties: false + properties: + onCreate: + type: string + LocalDevContainerDockerfile: + type: object + additionalProperties: false + required: + - type + properties: + type: + type: string + const: dockerfile + file: + type: string + type: object additionalProperties: false required: @@ -36,36 +86,9 @@ spec: $ref: /core/icon-value local: title: LocalDevContainer - type: object - additionalProperties: false - required: - - image - properties: - image: - type: string - options: - type: object - additionalProperties: true - userHome: - type: string - workingDir: - type: string - healthcheck: - type: string - HostConfig: - type: object - additionalProperties: true - Labels: - type: object - additionalProperties: true - Env: - type: array - items: - type: string - handlers: - title: LocalDevContainerHandlers - type: object - additionalProperties: false - properties: - onCreate: - type: string \ No newline at end of file + description: |- + if type is "docker" or empty - Local development container using a fixed docker image. User code will be mounted into the container. + if type is "dockerfile" - Local development container using a Dockerfile. User code will be built into the container. + oneOf: + - $ref: '#/definitions/LocalDevContainerDocker' + - $ref: '#/definitions/LocalDevContainerDockerfile'