/
components.go
126 lines (105 loc) · 4.38 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
126
package v1alpha1
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;Volume;Plugin;Custom
type ComponentType string
const (
ContainerComponentType ComponentType = "Container"
KubernetesComponentType ComponentType = "Kubernetes"
OpenshiftComponentType ComponentType = "Openshift"
PluginComponentType ComponentType = "Plugin"
VolumeComponentType ComponentType = "Volume"
CustomComponentType ComponentType = "Custom"
)
// 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 {
}
// +k8s:openapi-gen=true
// +union
type Component struct {
// Type of component
//
// +unionDiscriminator
// +optional
ComponentType ComponentType `json:"componentType,omitempty"`
// Allows adding and configuring workspace-related containers
// +optional
Container *ContainerComponent `json:"container,omitempty"`
// Allows specifying the definition of a volume
// shared by several other components
// +optional
Volume *VolumeComponent `json:"volume,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
Plugin *PluginComponent `json:"plugin,omitempty"`
// Allows importing into the workspace 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 workspace 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"`
// Custom component whose logic is implementation-dependant
// and should be provided by the user
// possibly through some dedicated controller
// +optional
Custom *CustomComponent `json:"custom,omitempty"`
}
type CustomComponent struct {
// Mandatory name that allows referencing the component
// in commands, or inside a parent
Name string `json:"name"`
// 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"`
}
// PluginComponentsOverrideType describes the type of components
// that can be overriden for a plugin.
// Only one of the following component type may be specified.
// +kubebuilder:validation:Enum=Container;Kubernetes;Openshift;Volume
type PluginComponentsOverrideType string
const (
ContainerPluginComponentsOverrideType PluginComponentsOverrideType = "Container"
KubernetesPluginComponentsOverrideType PluginComponentsOverrideType = "Kubernetes"
OpenshiftPluginComponentsOverrideType PluginComponentsOverrideType = "Openshift"
VolumePluginComponentsOverrideType PluginComponentsOverrideType = "Volume"
)
// +k8s:openapi-gen=true
// +union
type PluginComponentsOverride struct {
// Type of component override for a plugin
//
// +unionDiscriminator
// +optional
ComponentType PluginComponentsOverrideType `json:"componentType,omitempty"`
// Configuration overriding for a Container component in a plugin
// +optional
Container *ContainerComponent `json:"container,omitempty"`
// Configuration overriding for a Volume component in a plugin
// +optional
Volume *VolumeComponent `json:"volume,omitempty"`
// Configuration overriding for a Kubernetes component in a plugin
// +optional
Kubernetes *KubernetesComponent `json:"kubernetes,omitempty"`
// Configuration overriding for an OpenShift component in a plugin
// +optional
Openshift *OpenshiftComponent `json:"openshift,omitempty"`
}