Skip to content

Commit 13248b5

Browse files
committed
Add Image Comp, add Deploy Cmd Kind & handle conversion to v1alpha1
Signed-off-by: Maysun J Faisal <[email protected]>
1 parent 4f7b685 commit 13248b5

25 files changed

+7252
-125
lines changed

crds/workspace.devfile.io_devworkspaces.v1beta1.yaml

Lines changed: 443 additions & 0 deletions
Large diffs are not rendered by default.

crds/workspace.devfile.io_devworkspaces.yaml

Lines changed: 443 additions & 0 deletions
Large diffs are not rendered by default.

crds/workspace.devfile.io_devworkspacetemplates.v1beta1.yaml

Lines changed: 431 additions & 0 deletions
Large diffs are not rendered by default.

crds/workspace.devfile.io_devworkspacetemplates.yaml

Lines changed: 431 additions & 0 deletions
Large diffs are not rendered by default.

pkg/apis/workspaces/v1alpha1/conversion.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,15 @@ func convertDevWorkspaceTemplateSpecFrom_v1alpha2(src *v1alpha2.DevWorkspaceTemp
105105
}
106106
}
107107
for _, srcComponent := range src.Components {
108-
destComponent := Component{}
109-
err := convertComponentFrom_v1alpha2(&srcComponent, &destComponent)
110-
if err != nil {
111-
return err
108+
// Image Component is not present in v1alpha1
109+
if srcComponent.Image == nil {
110+
destComponent := Component{}
111+
err := convertComponentFrom_v1alpha2(&srcComponent, &destComponent)
112+
if err != nil {
113+
return err
114+
}
115+
dest.Components = append(dest.Components, destComponent)
112116
}
113-
dest.Components = append(dest.Components, destComponent)
114117
}
115118
for _, srcProject := range src.Projects {
116119
destProject := Project{}

pkg/apis/workspaces/v1alpha2/commands.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ const (
1818
)
1919

2020
// CommandGroupKind describes the kind of command group.
21-
// +kubebuilder:validation:Enum=build;run;test;debug
21+
// +kubebuilder:validation:Enum=build;run;test;debug;deploy
2222
type CommandGroupKind string
2323

2424
const (
25-
BuildCommandGroupKind CommandGroupKind = "build"
26-
RunCommandGroupKind CommandGroupKind = "run"
27-
TestCommandGroupKind CommandGroupKind = "test"
28-
DebugCommandGroupKind CommandGroupKind = "debug"
25+
BuildCommandGroupKind CommandGroupKind = "build"
26+
RunCommandGroupKind CommandGroupKind = "run"
27+
TestCommandGroupKind CommandGroupKind = "test"
28+
DebugCommandGroupKind CommandGroupKind = "debug"
29+
DeployCommandGroupKind CommandGroupKind = "deploy"
2930
)
3031

3132
type CommandGroup struct {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package v1alpha2
2+
3+
// ImageType describes the type of image.
4+
// Only one of the following image type may be specified.
5+
// +kubebuilder:validation:Enum=Dockerfile
6+
type ImageType string
7+
8+
const (
9+
DockerfileImageType ImageType = "Dockerfile"
10+
)
11+
12+
type BaseImage struct {
13+
}
14+
15+
// Component that allows the developer to build a runtime image for outerloop
16+
type ImageComponent struct {
17+
BaseComponent `json:",inline"`
18+
Image `json:",inline"`
19+
}
20+
21+
type Image struct {
22+
// Name of the image for the resulting outerloop build
23+
ImageName string `json:"imageName"`
24+
ImageUnion `json:",inline"`
25+
}
26+
27+
// +union
28+
type ImageUnion struct {
29+
// Type of image
30+
//
31+
// +unionDiscriminator
32+
// +optional
33+
ImageType ImageType `json:"imageType,omitempty"`
34+
35+
// Allows specifying dockerfile type build
36+
// +optional
37+
Dockerfile *DockerfileImage `json:"dockerfile,omitempty"`
38+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package v1alpha2
2+
3+
// DockerfileLocationType describes the type of
4+
// the location for the Dockerfile outerloop build.
5+
// Only one of the following location type may be specified.
6+
// +kubebuilder:validation:Enum=Uri;Id;Git
7+
type DockerfileLocationType string
8+
9+
const (
10+
UriLikeDockerfileLocationType DockerfileLocationType = "Uri"
11+
IdLikeDockerfileLocationType DockerfileLocationType = "Id"
12+
GitLikeDockerfileLocationType DockerfileLocationType = "Git"
13+
)
14+
15+
// Dockerfile Image type to specify the outerloop build using a Dockerfile
16+
type DockerfileImage struct {
17+
BaseImage `json:",inline"`
18+
DockerfileLocation `json:",inline"`
19+
Dockerfile `json:",inline"`
20+
21+
// Registry URL to pull the Dockerfile from when using id as Dockerfile src.
22+
// To ensure the dockerfile gets resolved consistently in different environments,
23+
// it is recommended to always specify the `regsitryURL` when `Id` is used.
24+
// +optional
25+
RegistryUrl string `json:"registryUrl,omitempty"`
26+
27+
// Location of the Dockerfile in the Git repository when using git as Dockerfile src.
28+
// +optional
29+
GitLocation string `json:"gitLocation,omitempty"`
30+
}
31+
32+
// +union
33+
type DockerfileLocation struct {
34+
// Type of Dockerfile location
35+
// +
36+
// +unionDiscriminator
37+
// +optional
38+
LocationType DockerfileLocationType `json:"locationType,omitempty"`
39+
40+
// URI Reference of a Dockerfile.
41+
// It can be a full URL or a relative URI from the current devfile as the base URI.
42+
// +optional
43+
Uri string `json:"uri,omitempty"`
44+
45+
// Id in a registry that contains a Dockerfile
46+
// +optional
47+
Id string `json:"id,omitempty"`
48+
49+
// Project's Git source
50+
// +optional
51+
Git *GitProjectSource `json:"git,omitempty"`
52+
}
53+
54+
type Dockerfile struct {
55+
// Path of source directory to establish build context. Defaults to ${PROJECT_ROOT} in the container
56+
// +optional
57+
BuildContext string `json:"buildContext,omitempty"`
58+
59+
// The arguments to supply to the dockerfile build.
60+
// +optional
61+
Args []string `json:"args,omitempty" patchStrategy:"replace"`
62+
63+
// Specify if a privileged builder pod is required.
64+
//
65+
// Default value is `false`
66+
// +optional
67+
RootRequired bool `json:"rootRequired,omitempty"`
68+
}

pkg/apis/workspaces/v1alpha2/components.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
// ComponentType describes the type of component.
99
// Only one of the following component type may be specified.
10-
// +kubebuilder:validation:Enum=Container;Kubernetes;Openshift;Volume;Plugin;Custom
10+
// +kubebuilder:validation:Enum=Container;Kubernetes;Openshift;Volume;Image;Plugin;Custom
1111
type ComponentType string
1212

1313
const (
@@ -16,6 +16,7 @@ const (
1616
OpenshiftComponentType ComponentType = "Openshift"
1717
PluginComponentType ComponentType = "Plugin"
1818
VolumeComponentType ComponentType = "Volume"
19+
ImageComponentType ComponentType = "Image"
1920
CustomComponentType ComponentType = "Custom"
2021
)
2122

@@ -72,6 +73,10 @@ type ComponentUnion struct {
7273
// +optional
7374
Volume *VolumeComponent `json:"volume,omitempty"`
7475

76+
// Allows specifying the definition of an image for outer loop builds
77+
// +optional
78+
Image *ImageComponent `json:"image,omitempty"`
79+
7580
// Allows importing a plugin.
7681
//
7782
// Plugins are mainly imported devfiles that contribute components, commands

0 commit comments

Comments
 (0)