-
Notifications
You must be signed in to change notification settings - Fork 60
/
components.go
125 lines (109 loc) · 4.44 KB
/
components.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//
//
// Copyright Red Hat
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package v1alpha2
import (
attributes "github.com/devfile/api/v2/pkg/attributes"
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;Volume;Image;Plugin;Custom
type ComponentType string
const (
ContainerComponentType ComponentType = "Container"
KubernetesComponentType ComponentType = "Kubernetes"
OpenshiftComponentType ComponentType = "Openshift"
PluginComponentType ComponentType = "Plugin"
VolumeComponentType ComponentType = "Volume"
ImageComponentType ComponentType = "Image"
CustomComponentType ComponentType = "Custom"
)
// DevWorkspace component: Anything that will bring additional features / tooling / behaviour / context
// to the devworkspace, in order to make working in it easier.
type BaseComponent struct {
}
// +k8s:openapi-gen=true
type Component struct {
// Mandatory name that allows referencing the component
// from other elements (such as commands) or from an external
// devfile that may reference this component through a parent or a plugin.
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
// +kubebuilder:validation:MaxLength=63
Name string `json:"name"`
// Map of implementation-dependant free-form YAML attributes.
// +optional
// +kubebuilder:validation:Type=object
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
Attributes attributes.Attributes `json:"attributes,omitempty"`
ComponentUnion `json:",inline"`
}
// +union
type ComponentUnion struct {
// Type of component
//
// +unionDiscriminator
// +optional
ComponentType ComponentType `json:"componentType,omitempty"`
// Allows adding and configuring devworkspace-related containers
// +optional
Container *ContainerComponent `json:"container,omitempty"`
// Allows importing into the devworkspace the Kubernetes resources
// defined in a given manifest. For example this allows reusing the Kubernetes
// definitions used to deploy some runtime components in production.
//
// +optional
Kubernetes *KubernetesComponent `json:"kubernetes,omitempty"`
// Allows importing into the devworkspace the OpenShift resources
// defined in a given manifest. For example this allows reusing the OpenShift
// definitions used to deploy some runtime components in production.
//
// +optional
Openshift *OpenshiftComponent `json:"openshift,omitempty"`
// Allows specifying the definition of a volume
// shared by several other components
// +optional
Volume *VolumeComponent `json:"volume,omitempty"`
// Allows specifying the definition of an image for outer loop builds
// +optional
Image *ImageComponent `json:"image,omitempty"`
// Allows importing a plugin.
//
// Plugins are mainly imported devfiles that contribute components, commands
// and events as a consistent single unit. They are defined in either YAML files
// following the devfile syntax,
// or as `DevWorkspaceTemplate` Kubernetes Custom Resources
// +optional
// +devfile:overrides:include:omitInPlugin=true
Plugin *PluginComponent `json:"plugin,omitempty"`
// Custom component whose logic is implementation-dependant
// and should be provided by the user
// possibly through some dedicated controller
// +optional
// +devfile:overrides:include:omit=true
Custom *CustomComponent `json:"custom,omitempty"`
}
type CustomComponent struct {
// Class of component that the associated implementation controller
// should use to process this command with the appropriate logic
ComponentClass string `json:"componentClass"`
// Additional free-form configuration for this custom component
// that the implementation controller will know how to use
//
// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:EmbeddedResource
EmbeddedResource runtime.RawExtension `json:"embeddedResource"`
}