@@ -69,15 +69,11 @@ type Configuration struct {
69
69
SchedulerName string `json:"schedulerName"`
70
70
// SeccompProfile names the seccomp profile workspaces will use
71
71
SeccompProfile string `json:"seccompProfile"`
72
- // Container configures all three workspace containers
73
- Container AllContainerConfiguration `json:"container"`
74
72
// Timeouts configures how long workspaces can be without activity before they're shut down.
75
73
// All values in here must be valid time.Duration
76
74
Timeouts WorkspaceTimeoutConfiguration `json:"timeouts"`
77
75
// InitProbe configures the ready-probe of workspaces which signal when the initialization is finished
78
76
InitProbe InitProbeConfiguration `json:"initProbe"`
79
- // WorkspacePodTemplate is a path to a workspace pod template YAML file
80
- WorkspacePodTemplate WorkspacePodTemplateConfiguration `json:"podTemplate,omitempty"`
81
77
// WorkspaceCACertSecret optionally names a secret which is mounted in `/etc/ssl/certs/gp-custom.crt`
82
78
// in all workspace pods.
83
79
WorkspaceCACertSecret string `json:"caCertSecret,omitempty"`
@@ -113,6 +109,13 @@ type Configuration struct {
113
109
RegistryFacadeHost string `json:"registryFacadeHost"`
114
110
// Cluster host under which workspaces are served, e.g. ws-eu11.gitpod.io
115
111
WorkspaceClusterHost string `json:"workspaceClusterHost"`
112
+ // WorkspaceClasses provide different resource classes for workspaces
113
+ WorkspaceClasses map [string ]* WorkspaceClass `json:"workspaceClass"`
114
+ }
115
+
116
+ type WorkspaceClass struct {
117
+ Container ContainerConfiguration `json:"container"`
118
+ Templates WorkspacePodTemplateConfiguration `json:"templates"`
116
119
}
117
120
118
121
// AllContainerConfiguration contains the configuration for all container in a workspace pod
@@ -185,10 +188,6 @@ type WorkspaceDaemonConfiguration struct {
185
188
186
189
// Validate validates the configuration to catch issues during startup and not at runtime
187
190
func (c * Configuration ) Validate () error {
188
- if err := c .Container .Workspace .Validate (); err != nil {
189
- return xerrors .Errorf ("container.workspace: %w" , err )
190
- }
191
-
192
191
err := validation .ValidateStruct (& c .Timeouts ,
193
192
validation .Field (& c .Timeouts .AfterClose , validation .Required ),
194
193
validation .Field (& c .Timeouts .HeadlessWorkspace , validation .Required ),
@@ -206,23 +205,33 @@ func (c *Configuration) Validate() error {
206
205
return xerrors .Errorf ("stopping timeout must be greater than content finalization timeout" )
207
206
}
208
207
209
- err = validation .ValidateStruct (& c .WorkspacePodTemplate ,
210
- validation .Field (& c .WorkspacePodTemplate .DefaultPath , validPodTemplate ),
211
- validation .Field (& c .WorkspacePodTemplate .PrebuildPath , validPodTemplate ),
212
- validation .Field (& c .WorkspacePodTemplate .ProbePath , validPodTemplate ),
213
- validation .Field (& c .WorkspacePodTemplate .RegularPath , validPodTemplate ),
214
- )
215
- if err != nil {
216
- return xerrors .Errorf ("workspacePodTemplate: %w" , err )
217
- }
218
-
219
208
err = validation .ValidateStruct (c ,
220
209
validation .Field (& c .WorkspaceURLTemplate , validation .Required , validWorkspaceURLTemplate ),
221
210
validation .Field (& c .WorkspaceHostPath , validation .Required ),
222
211
validation .Field (& c .HeartbeatInterval , validation .Required ),
223
212
validation .Field (& c .GitpodHostURL , validation .Required , is .URL ),
224
213
validation .Field (& c .ReconnectionInterval , validation .Required ),
225
214
)
215
+ if err != nil {
216
+ return err
217
+ }
218
+
219
+ for name , class := range c .WorkspaceClasses {
220
+ if err := class .Container .Validate (); err != nil {
221
+ return xerrors .Errorf ("workspace class %s: %w" , name , err )
222
+ }
223
+
224
+ err = validation .ValidateStruct (& class .Templates ,
225
+ validation .Field (& class .Templates .DefaultPath , validPodTemplate ),
226
+ validation .Field (& class .Templates .PrebuildPath , validPodTemplate ),
227
+ validation .Field (& class .Templates .ProbePath , validPodTemplate ),
228
+ validation .Field (& class .Templates .RegularPath , validPodTemplate ),
229
+ )
230
+ if err != nil {
231
+ return xerrors .Errorf ("workspace class %s: %w" , name , err )
232
+ }
233
+ }
234
+
226
235
return err
227
236
}
228
237
@@ -256,15 +265,13 @@ var validWorkspaceURLTemplate = validation.By(func(o interface{}) error {
256
265
257
266
// ContainerConfiguration configures properties of workspace pod container
258
267
type ContainerConfiguration struct {
259
- Image string `json:"image"`
260
- Requests ResourceConfiguration `json:"requests"`
261
- Limits ResourceConfiguration `json:"limits"`
268
+ Requests * ResourceConfiguration `json:"requests,omitempty"`
269
+ Limits * ResourceConfiguration `json:"limits,omitempty"`
262
270
}
263
271
264
272
// Validate validates a container configuration
265
273
func (c * ContainerConfiguration ) Validate () error {
266
274
return validation .ValidateStruct (c ,
267
- validation .Field (& c .Image , validation .Required ),
268
275
validation .Field (& c .Requests , validResourceConfig ),
269
276
validation .Field (& c .Limits , validResourceConfig ),
270
277
)
@@ -298,6 +305,9 @@ var validResourceConfig = validation.By(func(o interface{}) error {
298
305
299
306
// ResourceList parses the quantities in the resource config
300
307
func (r * ResourceConfiguration ) ResourceList () (corev1.ResourceList , error ) {
308
+ if r == nil {
309
+ return corev1.ResourceList {}, nil
310
+ }
301
311
res := map [corev1.ResourceName ]string {
302
312
corev1 .ResourceCPU : r .CPU ,
303
313
corev1 .ResourceMemory : r .Memory ,
0 commit comments