Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement agreed-on devfile 2.0 issues #35

Merged
merged 16 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 182 additions & 21 deletions deploy/crds/workspaces.ecd.eclipse.org_devworkspaces_crd.yaml

Large diffs are not rendered by default.

203 changes: 182 additions & 21 deletions deploy/crds/workspaces.ecd.eclipse.org_devworkspacetemplates_crd.yaml

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion devfile-support/samples/custom-devfile.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "my-devfile"
schemaVersion: "2.0.0-beta"
metadata:
name: "my-devfile"
projects:
- name: "my-project"
custom:
Expand All @@ -8,6 +9,7 @@ projects:
custom-info: "connexion-information"
components:
- kubernetes:
name: "production"
url: "https://somewhere/production-environment.yaml"
- custom:
componentClass: "NewComponentType"
Expand Down
26 changes: 17 additions & 9 deletions devfile-support/samples/nodejs-stack.devfile.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
schemaVersion: 2.0.0
name: nodejs-stack
metadata:
name: nodejs-stack
projects:
- name: project
git:
Expand Down Expand Up @@ -30,29 +31,36 @@ components:
mountSources: true
commands:
- exec:
alias: download dependencies
id: download dependencies
component: nodejs
commandLine: npm install
workdir: ${CHE_PROJECTS_ROOT}/project/app
workingDir: ${CHE_PROJECTS_ROOT}/project/app
group:
kind: build
- exec:
alias: run the app
id: run the app
amisevsk marked this conversation as resolved.
Show resolved Hide resolved
component: nodejs
commandLine: nodemon app.js
workdir: ${CHE_PROJECTS_ROOT}/project/app
workingDir: ${CHE_PROJECTS_ROOT}/project/app
group:
kind: run
isDefault: true
- exec:
alias: run the app (debugging enabled)
id: run the app (debugging enabled)
component: nodejs
commandLine: nodemon --inspect app.js
workdir: ${CHE_PROJECTS_ROOT}/project/app
workingDir: ${CHE_PROJECTS_ROOT}/project/app
group:
kind: run
- exec:
alias: stop the app
id: stop the app
component: nodejs
commandLine: >-
node_server_pids=$(pgrep -fx '.*nodemon (--inspect )?app.js' | tr "\\n" " ") &&
echo "Stopping node server with PIDs: ${node_server_pids}" &&
kill -15 ${node_server_pids} &>/dev/null && echo 'Done.'
- vscodeLaunch:
alias: Attach remote debugger
id: Attach remote debugger
inlined: |
{
"version": "0.2.0",
Expand Down
4 changes: 3 additions & 1 deletion devfile-support/samples/sample-devfile.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "devfile example"
schemaVersion: "2.0.0"
metadata:
name: "devfile example"
davidfestal marked this conversation as resolved.
Show resolved Hide resolved
projects:
- name: "my-project"
custom:
Expand Down Expand Up @@ -37,4 +38,5 @@ components:
field2: ""
name: "myNewComponent"
- kubernetes:
name: "production"
url: "https://somewhere/production-environment.yaml"
24 changes: 20 additions & 4 deletions devfile-support/samples/simple-devfile.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
name: "myDevile"
schemaVersion: "2.0.0"
metadata:
name: "myDevile"
projects:
- name: "devworkspace-spec"
git:
location: "https://github.com/che-incubator/devworkspace-api"
branch: "master"
commands:
- exec:
id: buildSchema
label: Build the schema
commandLine: "./buildSchema.sh"
component: build-tools
alias: buildSchema
group:
kind: build
isDefault: true
- vscodeTask:
alias: openDevfile
id: openDevfile
inlined:
json
- composite:
id: buildSchemaAndOpenDevfile
Label: Build schema and open devfile
commands:
- buildSchema
- openDevfile
parallel: false
- exec:
id: helloWorld
env:
- name: "USER"
value: "John Doe"
commandLine: 'echo "Hello ${USER}"'
- custom:
id: myCustomCommand
commandClass: myCommandType
embeddedResource:
myEmbeddedObject:
Expand All @@ -38,4 +51,7 @@ components:
registryUrl: "external-registry-url"
- container:
image: some container image with required build tools
name: "build-tools"
mountSources: true
sourceMapping: /home/src
name: "build-tools"

davidfestal marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 3 additions & 1 deletion devfile-support/samples/with-nodejs-parent.devfile.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: with-parent
schemaVersion: 2.0.0
metadata:
name: with-parent
parent:
uri: https://raw.githubusercontent.com/che-incubator/devworkspace-api/proposal-25-variant-1-define-stacks/devfile-support/samples/nodejs-stack.devfile.yaml
commands:
- exec:
id: sayHello
label: Say Hello
commandLine: echo "hello"
component: nodejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"op": "add",
"path": "/properties/metadata",
"value": { "type": "object", "description": "Optional metadata", "properties": {} }
},
{
"op": "add",
"path": "/properties/metadata/properties/version",
"value": { "type": "string", "description": "Optional semver-compatible version", "pattern": "^([1-9]+)\\.([0-9]+)\\.([0-9]+)(\\-[0-9a-z-]+(\\.[0-9a-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" }
},
{
"op": "add",
"path": "/properties/metadata/properties/name",
"value": { "type": "string", "description": "Optional devfile name" }
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
"path": "/description",
"value": "Devfile schema."
},
{
"op": "add",
"path": "/properties/name",
"value": { "type": "string", "description": "devfile name" }
},
{
"op": "add",
"path": "/properties/schemaVersion",
Expand All @@ -17,6 +12,6 @@
{
"op": "add",
"path": "/required",
"value": [ "name", "schemaVersion" ]
"value": [ "schemaVersion" ]
}
]
48 changes: 43 additions & 5 deletions pkg/apis/workspaces/v1alpha1/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,47 @@ const (
CustomCommandType CommandType = "Custom"
)

// CommandGroupType describes the kind of command group.
// +kubebuilder:validation:Enum=build;run;test;debug
type CommandGroupType string

const (
BuildCommandGroupType CommandGroupType = "build"
RunCommandGroupType CommandGroupType = "run"
TestCommandGroupType CommandGroupType = "test"
DebugCommandGroupType CommandGroupType = "debug"
)

type CommandGroup struct {
// Kind of group the command is part of
Kind CommandGroupType `json:"kind"`

// +optional
// Identifies the default command for a given group kind
IsDefault bool `json:"isDefault,omitempty"`
davidfestal marked this conversation as resolved.
Show resolved Hide resolved
}

type BaseCommand struct {
Alias string `json:"alias,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"` // Additional command attributes
// Mandatory identifier that allows referencing
// this command in composite commands, or from
// a parent, or in events.
Id string `json:"id"`

// +optional
// Defines the group this command is part of
Group *CommandGroup `json:"group,omitempty"`

// Optional map of free-form additional command attributes
Attributes map[string]string `json:"attributes,omitempty"`
}

type LabeledCommand struct {
BaseCommand `json:",inline"`
Label string `json:"label,omitempty"`

// +optional
// Optional label that provides a label for this command
// to be used in Editor UI menus for example
Label string `json:"label,omitempty"`
}

type Command struct {
Expand Down Expand Up @@ -68,7 +101,12 @@ type ExecCommand struct {
Component string `json:"component,omitempty"`

// Working directory where the command should be executed
Workdir string `json:"workdir,omitempty"`
WorkingDir string `json:"workingDir,omitempty"`

// +optional
// Optional list of environment variables that have to be set
// before running the command
Env []EnvVar `json:"env,omitempty"`
}

type CompositeCommand struct {
Expand Down Expand Up @@ -100,7 +138,7 @@ type VscodeConfigurationCommandLocation struct {
}

type VscodeConfigurationCommand struct {
BaseCommand `json:",inline"`
BaseCommand `json:",inline"`
VscodeConfigurationCommandLocation `json:",inline"`
}

Expand Down
1 change: 0 additions & 1 deletion pkg/apis/workspaces/v1alpha1/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const (
// Workspace component: Anything that will bring additional features / tooling / behaviour / context
// to the workspace, in order to make working in it easier.
type BaseComponent struct {
Alias string `json:"alias,omitempty"`
}

type Component struct {
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/workspaces/v1alpha1/containerComponent.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@ type Container struct {
Volumes []Volume `json:"volumes,omitempty"`
//+optional
MemoryLimit string `json:"memoryLimit,omitempty"`

//+optional
MountSources bool `json:"mountSources"`

//+optional
//
// Optional specification of the path in the container where
// project sources should be transferred/mounted when `mountSources` is `true`.
// When omitted, the value of the `PROJECT_SOURCE` environment variable is used.
SourceMapping string `json:"sourceMapping"`
}

type EnvVar struct {
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/workspaces/v1alpha1/kubernetesLikeComponent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package v1alpha1
// +k8s:openapi-gen=true
// +union
type K8sLikeComponentLocation struct {
// Optional name that allows referencing the component
// in commands, or inside a parent
Name string `json:"name"`

// Type of Kubernetes-like location
// +
// +unionDiscriminator
Expand All @@ -20,7 +24,7 @@ type K8sLikeComponentLocation struct {

type K8sLikeComponent struct {
BaseComponent `json:",inline"`
Location K8sLikeComponentLocation `json:",inline"`
Location K8sLikeComponentLocation `json:",inline"`
amisevsk marked this conversation as resolved.
Show resolved Hide resolved
}

// Component that allows partly importing Kubernetes resources into the workspace POD
Expand Down
15 changes: 11 additions & 4 deletions pkg/apis/workspaces/v1alpha1/pluginLikeComponents.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1alpha1

type RegistryEntryPluginLocation struct {
Id string `json:"id"`
Id string `json:"id"`

// +optional
BaseUrl string `json:"baseUrl,omitempty"`
Expand All @@ -13,8 +13,8 @@ type RegistryEntryPluginLocation struct {
type PluginLocationType string

const (
RegistryEntryPluginLocationType PluginLocationType = "RegistryEntry"
UriPluginLocationType PluginLocationType = "Uri"
RegistryEntryPluginLocationType PluginLocationType = "RegistryEntry"
UriPluginLocationType PluginLocationType = "Uri"
)

// +k8s:openapi-gen=true
Expand All @@ -37,7 +37,14 @@ type ChePluginLocation struct {

type PluginLikeComponent struct {
BaseComponent `json:",inline"`
MemoryLimit string `json:"memoryLimit,omitempty"`

// +optional
// Optional name that allows referencing the component
// in commands, or inside a parent
// If omitted it will be infered from the location (uri or registryEntry)
Name string `json:"name,omitempty"`

MemoryLimit string `json:"memoryLimit,omitempty"`
ChePluginLocation `json:",inline"`
}

Expand Down
26 changes: 26 additions & 0 deletions pkg/apis/workspaces/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading