Skip to content

Commit

Permalink
feat: Add type to local image and support for dockerfiles (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
hofmeister authored Feb 24, 2024
1 parent 3c753e4 commit b2e501b
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 174 deletions.
10 changes: 8 additions & 2 deletions packages/go/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
123 changes: 78 additions & 45 deletions packages/go/schemas/concepts/core/language-target.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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"
}
}
]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.kapeta</groupId>
<artifactId>schemas</artifactId>
<version>3.3.0</version>
<version>3.4.0</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Data schemas for Kapeta</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> env;
Expand All @@ -12,6 +18,8 @@ public class LocalDevContainer {
private String image;
private Map<String, Object> labels;
private Map<String, Object> options;
private String type;
private String userHome;
private String workingDir;
private String file;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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"
}
}
]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/npm/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Loading

0 comments on commit b2e501b

Please sign in to comment.