diff --git a/deploy/crds/workspaces.ecd.eclipse.org_devworkspaces_crd.yaml b/deploy/crds/workspaces.ecd.eclipse.org_devworkspaces_crd.yaml index b539fba2b..36d51361b 100644 --- a/deploy/crds/workspaces.ecd.eclipse.org_devworkspaces_crd.yaml +++ b/deploy/crds/workspaces.ecd.eclipse.org_devworkspaces_crd.yaml @@ -414,6 +414,7 @@ spec: type: object type: array env: + description: Environment variables used in this container items: properties: name: @@ -439,22 +440,28 @@ spec: when `mountSources` is `true`. When omitted, the value of the `PROJECT_ROOT` environment variable is used. type: string - volumes: + volumeMounts: + description: List of volumes mounts that should be mounted + is this container. items: description: Volume that should be mounted to a component container properties: - mountPath: - type: string name: - description: The volume name. If several components - mount the same volume then they will reuse the - volume and will be able to access to the same - files + description: The volume mount name is the name of + an existing `Volume` component. If no corresponding + `Volume` component exist it is implicitly added. + If several containers mount the same volume name + then they will reuse the same volume and will + be able to access to the same files. + type: string + path: + description: The path in the component container + where the volume should be mounted type: string required: - - mountPath - name + - path type: object type: array required: @@ -520,9 +527,24 @@ spec: - Kubernetes - Openshift - CheEditor + - Volume - ChePlugin - Custom type: string + volume: + description: Volume component + properties: + name: + description: Mandatory name that allows referencing the + Volume component in Container volume mounts or inside + a parent + type: string + size: + description: Size of the volume + type: string + required: + - name + type: object type: object type: array parent: diff --git a/deploy/crds/workspaces.ecd.eclipse.org_devworkspacetemplates_crd.yaml b/deploy/crds/workspaces.ecd.eclipse.org_devworkspacetemplates_crd.yaml index d2df436c2..bdeb6b387 100644 --- a/deploy/crds/workspaces.ecd.eclipse.org_devworkspacetemplates_crd.yaml +++ b/deploy/crds/workspaces.ecd.eclipse.org_devworkspacetemplates_crd.yaml @@ -404,6 +404,7 @@ spec: type: object type: array env: + description: Environment variables used in this container items: properties: name: @@ -429,21 +430,28 @@ spec: `mountSources` is `true`. When omitted, the value of the `PROJECT_ROOT` environment variable is used. type: string - volumes: + volumeMounts: + description: List of volumes mounts that should be mounted + is this container. items: description: Volume that should be mounted to a component container properties: - mountPath: - type: string name: - description: The volume name. If several components - mount the same volume then they will reuse the volume - and will be able to access to the same files + description: The volume mount name is the name of an + existing `Volume` component. If no corresponding `Volume` + component exist it is implicitly added. If several + containers mount the same volume name then they will + reuse the same volume and will be able to access to + the same files. + type: string + path: + description: The path in the component container where + the volume should be mounted type: string required: - - mountPath - name + - path type: object type: array required: @@ -509,9 +517,23 @@ spec: - Kubernetes - Openshift - CheEditor + - Volume - ChePlugin - Custom type: string + volume: + description: Volume component + properties: + name: + description: Mandatory name that allows referencing the Volume + component in Container volume mounts or inside a parent + type: string + size: + description: Size of the volume + type: string + required: + - name + type: object type: object type: array parent: diff --git a/pkg/apis/workspaces/v1alpha1/components.go b/pkg/apis/workspaces/v1alpha1/components.go index e5c2b90b3..9120a2f4d 100644 --- a/pkg/apis/workspaces/v1alpha1/components.go +++ b/pkg/apis/workspaces/v1alpha1/components.go @@ -4,7 +4,7 @@ import runtime "k8s.io/apimachinery/pkg/runtime" // ComponentType describes the type of component. // Only one of the following component type may be specified. -// +kubebuilder:validation:Enum= Container;Kubernetes;Openshift;CheEditor;ChePlugin;Custom +// +kubebuilder:validation:Enum= Container;Kubernetes;Openshift;CheEditor;Volume;ChePlugin;Custom type ComponentType string const ( @@ -13,6 +13,7 @@ const ( OpenshiftComponentType ComponentType = "Openshift" CheEditorComponentType ComponentType = "CheEditor" ChePluginComponentType ComponentType = "ChePlugin" + VolumeComponentType ComponentType = "Volume" CustomComponentType ComponentType = "Custom" ) @@ -40,6 +41,10 @@ type PolymorphicComponent struct { // +optional Container *ContainerComponent `json:"container,omitempty"` + // Volume component + // +optional + Volume *VolumeComponent `json:"volume,omitempty"` + // CheEditor component // +optional CheEditor *CheEditorComponent `json:"cheEditor,omitempty"` diff --git a/pkg/apis/workspaces/v1alpha1/containerComponent.go b/pkg/apis/workspaces/v1alpha1/containerComponent.go index c1c106a79..4efb6a235 100644 --- a/pkg/apis/workspaces/v1alpha1/containerComponent.go +++ b/pkg/apis/workspaces/v1alpha1/containerComponent.go @@ -44,15 +44,19 @@ type Container struct { Name string `json:"name"` Image string `json:"image"` // +optional + // Environment variables used in this container Env []EnvVar `json:"env,omitempty"` + // +optional - Volumes []Volume `json:"volumes,omitempty"` + // List of volumes mounts that should be mounted is this container. + VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"` + //+optional MemoryLimit string `json:"memoryLimit,omitempty"` - + //+optional MountSources bool `json:"mountSources"` - + //+optional // // Optional specification of the path in the container where @@ -67,11 +71,13 @@ type EnvVar struct { } // Volume that should be mounted to a component container -type Volume struct { - // The volume name. - // If several components mount the same volume then they will reuse the volume - // and will be able to access to the same files +type VolumeMount struct { + // The volume mount name is the name of an existing `Volume` component. + // If no corresponding `Volume` component exist it is implicitly added. + // If several containers mount the same volume name + // then they will reuse the same volume and will be able to access to the same files. Name string `json:"name"` - MountPath string `json:"mountPath"` + // The path in the component container where the volume should be mounted + Path string `json:"path"` } diff --git a/pkg/apis/workspaces/v1alpha1/volumeComponent.go b/pkg/apis/workspaces/v1alpha1/volumeComponent.go new file mode 100644 index 000000000..bb47d4633 --- /dev/null +++ b/pkg/apis/workspaces/v1alpha1/volumeComponent.go @@ -0,0 +1,18 @@ +package v1alpha1 + +// Component that allows the developer to declare and configure a volume into his workspace +type VolumeComponent struct { + BaseComponent `json:",inline"` + Volume `json:",inline"` +} + +// Volume that should be mounted to a component container +type Volume struct { + // Mandatory name that allows referencing the Volume component + // in Container volume mounts or inside a parent + Name string `json:"name"` + + // +optional + // Size of the volume + Size string `json:"size,omitempty"` +} diff --git a/pkg/apis/workspaces/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/workspaces/v1alpha1/zz_generated.deepcopy.go index 27804d942..f1974f53c 100644 --- a/pkg/apis/workspaces/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/workspaces/v1alpha1/zz_generated.deepcopy.go @@ -204,9 +204,9 @@ func (in *Container) DeepCopyInto(out *Container) { *out = make([]EnvVar, len(*in)) copy(*out, *in) } - if in.Volumes != nil { - in, out := &in.Volumes, &out.Volumes - *out = make([]Volume, len(*in)) + if in.VolumeMounts != nil { + in, out := &in.VolumeMounts, &out.VolumeMounts + *out = make([]VolumeMount, len(*in)) copy(*out, *in) } return @@ -846,6 +846,11 @@ func (in *PolymorphicComponent) DeepCopyInto(out *PolymorphicComponent) { *out = new(ContainerComponent) (*in).DeepCopyInto(*out) } + if in.Volume != nil { + in, out := &in.Volume, &out.Volume + *out = new(VolumeComponent) + **out = **in + } if in.CheEditor != nil { in, out := &in.CheEditor, &out.CheEditor *out = new(CheEditorComponent) @@ -985,6 +990,40 @@ func (in *Volume) DeepCopy() *Volume { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeComponent) DeepCopyInto(out *VolumeComponent) { + *out = *in + out.BaseComponent = in.BaseComponent + out.Volume = in.Volume + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeComponent. +func (in *VolumeComponent) DeepCopy() *VolumeComponent { + if in == nil { + return nil + } + out := new(VolumeComponent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeMount) DeepCopyInto(out *VolumeMount) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeMount. +func (in *VolumeMount) DeepCopy() *VolumeMount { + if in == nil { + return nil + } + out := new(VolumeMount) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VscodeConfigurationCommand) DeepCopyInto(out *VscodeConfigurationCommand) { *out = *in diff --git a/pkg/apis/workspaces/v1alpha1/zz_generated.openapi.go b/pkg/apis/workspaces/v1alpha1/zz_generated.openapi.go index b79f9703c..bd16f4091 100644 --- a/pkg/apis/workspaces/v1alpha1/zz_generated.openapi.go +++ b/pkg/apis/workspaces/v1alpha1/zz_generated.openapi.go @@ -488,6 +488,12 @@ func schema_pkg_apis_workspaces_v1alpha1_PolymorphicComponent(ref common.Referen Ref: ref("github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.ContainerComponent"), }, }, + "volume": { + SchemaProps: spec.SchemaProps{ + Description: "Volume component", + Ref: ref("github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.VolumeComponent"), + }, + }, "cheEditor": { SchemaProps: spec.SchemaProps{ Description: "CheEditor component", @@ -532,6 +538,7 @@ func schema_pkg_apis_workspaces_v1alpha1_PolymorphicComponent(ref common.Referen "custom": "Custom", "kubernetes": "Kubernetes", "openshift": "Openshift", + "volume": "Volume", }, }, }, @@ -539,7 +546,7 @@ func schema_pkg_apis_workspaces_v1alpha1_PolymorphicComponent(ref common.Referen }, }, Dependencies: []string{ - "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.CheEditorComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.ChePluginComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.ContainerComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.CustomComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.KubernetesComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.OpenshiftComponent"}, + "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.CheEditorComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.ChePluginComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.ContainerComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.CustomComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.KubernetesComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.OpenshiftComponent", "github.com/che-incubator/devworkspace-api/pkg/apis/workspaces/v1alpha1.VolumeComponent"}, } } diff --git a/schemas/devfile.json b/schemas/devfile.json index 8529c5a49..b2255907c 100644 --- a/schemas/devfile.json +++ b/schemas/devfile.json @@ -470,6 +470,7 @@ "type": "array" }, "env": { + "description": "Environment variables used in this container", "items": { "properties": { "name": { @@ -503,21 +504,23 @@ "description": "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_ROOT` environment variable is used.", "type": "string" }, - "volumes": { + "volumeMounts": { + "description": "List of volumes mounts that should be mounted is this container.", "items": { "description": "Volume that should be mounted to a component container", "properties": { - "mountPath": { + "name": { + "description": "The volume mount name is the name of an existing `Volume` component. If no corresponding `Volume` component exist it is implicitly added. If several containers mount the same volume name then they will reuse the same volume and will be able to access to the same files.", "type": "string" }, - "name": { - "description": "The volume name. If several components mount the same volume then they will reuse the volume and will be able to access to the same files", + "path": { + "description": "The path in the component container where the volume should be mounted", "type": "string" } }, "required": [ - "mountPath", - "name" + "name", + "path" ], "type": "object" }, @@ -607,10 +610,28 @@ "Kubernetes", "Openshift", "CheEditor", + "Volume", "ChePlugin", "Custom" ], "type": "string" + }, + "volume": { + "description": "Volume component", + "properties": { + "name": { + "description": "Mandatory name that allows referencing the Volume component in Container volume mounts or inside a parent", + "type": "string" + }, + "size": { + "description": "Size of the volume", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" } }, "type": "object" diff --git a/schemas/devworkspace-template-spec.json b/schemas/devworkspace-template-spec.json index e3430af16..f97a57a86 100644 --- a/schemas/devworkspace-template-spec.json +++ b/schemas/devworkspace-template-spec.json @@ -470,6 +470,7 @@ "type": "array" }, "env": { + "description": "Environment variables used in this container", "items": { "properties": { "name": { @@ -503,21 +504,23 @@ "description": "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_ROOT` environment variable is used.", "type": "string" }, - "volumes": { + "volumeMounts": { + "description": "List of volumes mounts that should be mounted is this container.", "items": { "description": "Volume that should be mounted to a component container", "properties": { - "mountPath": { + "name": { + "description": "The volume mount name is the name of an existing `Volume` component. If no corresponding `Volume` component exist it is implicitly added. If several containers mount the same volume name then they will reuse the same volume and will be able to access to the same files.", "type": "string" }, - "name": { - "description": "The volume name. If several components mount the same volume then they will reuse the volume and will be able to access to the same files", + "path": { + "description": "The path in the component container where the volume should be mounted", "type": "string" } }, "required": [ - "mountPath", - "name" + "name", + "path" ], "type": "object" }, @@ -607,10 +610,28 @@ "Kubernetes", "Openshift", "CheEditor", + "Volume", "ChePlugin", "Custom" ], "type": "string" + }, + "volume": { + "description": "Volume component", + "properties": { + "name": { + "description": "Mandatory name that allows referencing the Volume component in Container volume mounts or inside a parent", + "type": "string" + }, + "size": { + "description": "Size of the volume", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" } }, "type": "object" diff --git a/schemas/devworkspace-template.json b/schemas/devworkspace-template.json index 580a8d01f..a381b8712 100644 --- a/schemas/devworkspace-template.json +++ b/schemas/devworkspace-template.json @@ -484,6 +484,7 @@ "type": "array" }, "env": { + "description": "Environment variables used in this container", "items": { "properties": { "name": { @@ -517,21 +518,23 @@ "description": "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_ROOT` environment variable is used.", "type": "string" }, - "volumes": { + "volumeMounts": { + "description": "List of volumes mounts that should be mounted is this container.", "items": { "description": "Volume that should be mounted to a component container", "properties": { - "mountPath": { + "name": { + "description": "The volume mount name is the name of an existing `Volume` component. If no corresponding `Volume` component exist it is implicitly added. If several containers mount the same volume name then they will reuse the same volume and will be able to access to the same files.", "type": "string" }, - "name": { - "description": "The volume name. If several components mount the same volume then they will reuse the volume and will be able to access to the same files", + "path": { + "description": "The path in the component container where the volume should be mounted", "type": "string" } }, "required": [ - "mountPath", - "name" + "name", + "path" ], "type": "object" }, @@ -621,10 +624,28 @@ "Kubernetes", "Openshift", "CheEditor", + "Volume", "ChePlugin", "Custom" ], "type": "string" + }, + "volume": { + "description": "Volume component", + "properties": { + "name": { + "description": "Mandatory name that allows referencing the Volume component in Container volume mounts or inside a parent", + "type": "string" + }, + "size": { + "description": "Size of the volume", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" } }, "type": "object" diff --git a/schemas/devworkspace.json b/schemas/devworkspace.json index 15770632d..3fafbfd00 100644 --- a/schemas/devworkspace.json +++ b/schemas/devworkspace.json @@ -493,6 +493,7 @@ "type": "array" }, "env": { + "description": "Environment variables used in this container", "items": { "properties": { "name": { @@ -526,21 +527,23 @@ "description": "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_ROOT` environment variable is used.", "type": "string" }, - "volumes": { + "volumeMounts": { + "description": "List of volumes mounts that should be mounted is this container.", "items": { "description": "Volume that should be mounted to a component container", "properties": { - "mountPath": { + "name": { + "description": "The volume mount name is the name of an existing `Volume` component. If no corresponding `Volume` component exist it is implicitly added. If several containers mount the same volume name then they will reuse the same volume and will be able to access to the same files.", "type": "string" }, - "name": { - "description": "The volume name. If several components mount the same volume then they will reuse the volume and will be able to access to the same files", + "path": { + "description": "The path in the component container where the volume should be mounted", "type": "string" } }, "required": [ - "mountPath", - "name" + "name", + "path" ], "type": "object" }, @@ -630,10 +633,28 @@ "Kubernetes", "Openshift", "CheEditor", + "Volume", "ChePlugin", "Custom" ], "type": "string" + }, + "volume": { + "description": "Volume component", + "properties": { + "name": { + "description": "Mandatory name that allows referencing the Volume component in Container volume mounts or inside a parent", + "type": "string" + }, + "size": { + "description": "Size of the volume", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" } }, "type": "object"