|
1 | 1 | package main
|
2 | 2 |
|
3 |
| -import "net/http" |
| 3 | +import ( |
| 4 | + "net/http" |
4 | 5 |
|
5 |
| -// ConfigurationsConfiguration Struct. |
6 |
| -type ConfigurationsConfiguration struct { |
7 |
| - Value []string `yaml:"value" json:"value"` |
8 |
| - ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 6 | + corev1 "k8s.io/api/core/v1" |
| 7 | +) |
| 8 | + |
| 9 | +type SpawnerFormDefaults struct { |
| 10 | + Image Image `yaml:"image" json:"image"` |
| 11 | + ImageGroupOne ImageGroup `yaml:"imageGroupOne" json:"imageGroupOne"` |
| 12 | + ImageGroupTwo ImageGroup `yaml:"imageGroupTwo" json:"imageGroupTwo"` |
| 13 | + AllowCustomImage bool `yaml:"allowCustomImage" json:"allowCustomImage"` |
| 14 | + ImagePullPolicy ImagePullPolicy `yaml:"imagePullPolicy" json:"imagePullPolicy"` |
| 15 | + CPU CPU `yaml:"cpu" json:"cpu"` |
| 16 | + Memory CPU `yaml:"memory" json:"memory"` |
| 17 | + WorkspaceVolume WorkspaceVolume `yaml:"workspaceVolume" json:"workspaceVolume"` |
| 18 | + DataVolumes DataVolumes `yaml:"dataVolumes" json:"dataVolumes"` |
| 19 | + GPUs GPUs `yaml:"gpus" json:"gpus"` |
| 20 | + Shm Shm `yaml:"shm" json:"shm"` |
| 21 | + Configurations Configurations `yaml:"configurations" json:"configurations"` |
| 22 | + AffinityConfig AffinityConfig `yaml:"affinityConfig" json:"affinityConfig"` |
| 23 | + TolerationGroup TolerationGroup `yaml:"tolerationGroup" json:"tolerationGroup"` |
9 | 24 | }
|
10 | 25 |
|
11 |
| -// SharedMemoryConfiguration Struct. |
12 |
| -type SharedMemoryConfiguration struct { |
13 |
| - Value bool `yaml:"value" json:"value"` |
14 |
| - ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 26 | +type AffinityConfig struct { |
| 27 | + Value string `yaml:"value" json:"value"` |
| 28 | + Options []AffinityConfigOption `yaml:"options" json:"options"` |
| 29 | + ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
15 | 30 | }
|
16 | 31 |
|
17 |
| -// GPUVendorConfiguration Struct. |
18 |
| -type GPUVendorConfiguration struct { |
19 |
| - LimitsKey string `yaml:"limitsKey" json:"limitsKey"` |
20 |
| - UIName string `yaml:"uiName" json:"uiName"` |
| 32 | +type AffinityConfigOption struct { |
| 33 | + ConfigKey string `yaml:"configKey" json:"configKey"` |
| 34 | + DisplayName string `yaml:"displayName" json:"displayName"` |
| 35 | + Affinity corev1.Affinity `yaml:"affinity" json:"affinity"` |
21 | 36 | }
|
22 | 37 |
|
23 |
| -// GPUValueConfiguration Struct. |
24 |
| -type GPUValueConfiguration struct { |
25 |
| - Quantity string `yaml:"num" json:"num"` |
26 |
| - Vendors []GPUVendorConfiguration `yaml:"vendors" json:"vendors"` |
27 |
| - Vendor string `yaml:"vendor" json:"vendor"` |
| 38 | +type LabelSelectorMatchExpression struct { |
| 39 | + Key string `yaml:"key" json:"key"` |
| 40 | + Operator string `yaml:"operator" json:"operator"` |
28 | 41 | }
|
29 | 42 |
|
30 |
| -// GPUConfiguration Struct. |
31 |
| -type GPUConfiguration struct { |
32 |
| - Value GPUValueConfiguration `yaml:"value" json:"value"` |
33 |
| - ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 43 | +type CPU struct { |
| 44 | + Value string `yaml:"value" json:"value"` |
| 45 | + LimitFactor string `yaml:"limitFactor" json:"limitFactor"` |
| 46 | + ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
34 | 47 | }
|
35 | 48 |
|
36 |
| -// ValueConfiguration Struct. |
37 |
| -type ValueConfiguration struct { |
38 |
| - Value string `yaml:"value" json:"value"` |
| 49 | +type Configurations struct { |
| 50 | + Value []string `yaml:"value" json:"value"` |
| 51 | + ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 52 | +} |
| 53 | + |
| 54 | +type DataVolumes struct { |
| 55 | + Value []ValueElement `yaml:"value" json:"value"` |
| 56 | + ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 57 | +} |
| 58 | + |
| 59 | +type ValueElement struct { |
| 60 | + Value ValueValue `yaml:"value" json:"value"` |
39 | 61 | }
|
40 | 62 |
|
41 |
| -// VolumeValueConfiguration Struct. |
42 |
| -type VolumeValueConfiguration struct { |
43 |
| - Type ValueConfiguration `yaml:"type" json:"type"` |
44 |
| - Name ValueConfiguration `yaml:"name" json:"name"` |
45 |
| - Size ValueConfiguration `yaml:"size" json:"size"` |
46 |
| - MountPath ValueConfiguration `yaml:"mountPath" json:"mountPath"` |
47 |
| - AccessModes ValueConfiguration `yaml:"accessModes" json:"accessModes"` |
48 |
| - Class ValueConfiguration `yaml:"class" json:"class"` |
| 63 | +type ValueValue struct { |
| 64 | + Type ImagePullPolicy `yaml:"type" json:"type"` |
| 65 | + Name ImagePullPolicy `yaml:"name" json:"name"` |
| 66 | + Size ImagePullPolicy `yaml:"size" json:"size"` |
| 67 | + MountPath ImagePullPolicy `yaml:"mountPath" json:"mountPath"` |
| 68 | + AccessModes ImagePullPolicy `yaml:"accessModes" json:"accessModes"` |
| 69 | + Class ImagePullPolicy `yaml:"class" json:"class"` |
49 | 70 | }
|
50 | 71 |
|
51 |
| -// DataVolumesConfiguration Struct. |
52 |
| -type DataVolumesConfiguration struct { |
53 |
| - Values []VolumeValueConfiguration `yaml:"value" json:"value"` |
54 |
| - ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 72 | +type ImagePullPolicy struct { |
| 73 | + Value string `yaml:"value" json:"value"` |
55 | 74 | }
|
56 | 75 |
|
57 |
| -// WorkspaceVolumeConfiguration Struct. |
58 |
| -type WorkspaceVolumeConfiguration struct { |
59 |
| - Value VolumeValueConfiguration `yaml:"value" json:"value"` |
60 |
| - ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 76 | +type GPUs struct { |
| 77 | + Value GpusValue `yaml:"value" json:"value"` |
| 78 | + ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
61 | 79 | }
|
62 | 80 |
|
63 |
| -// ResourceConfiguration Struct. |
64 |
| -type ResourceConfiguration struct { |
65 |
| - Value string `yaml:"value" json:"value"` |
66 |
| - ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 81 | +type GpusValue struct { |
| 82 | + Num string `yaml:"num" json:"num"` |
| 83 | + Vendors []Vendor `yaml:"vendors" json:"vendors"` |
| 84 | + Vendor string `yaml:"vendor" json:"vendor"` |
67 | 85 | }
|
68 | 86 |
|
69 |
| -// ImageConfiguration Struct. |
70 |
| -type ImageConfiguration struct { |
| 87 | +type Vendor struct { |
| 88 | + LimitsKey string `yaml:"limitsKey" json:"limitsKey"` |
| 89 | + UIName string `yaml:"uiName" json:"uiName"` |
| 90 | +} |
| 91 | + |
| 92 | +type Image struct { |
71 | 93 | Value string `yaml:"value" json:"value"`
|
72 | 94 | Options []string `yaml:"options" json:"options"`
|
73 | 95 | ReadOnly bool `yaml:"readOnly" json:"readOnly"`
|
74 | 96 | HideRegistry bool `yaml:"hideRegistry" json:"hideRegistry"`
|
75 | 97 | HideVersion bool `yaml:"hideVersion" json:"hideVersion"`
|
76 | 98 | }
|
77 | 99 |
|
78 |
| -// SpawnerFormDefaults Struct. |
79 |
| -type SpawnerFormDefaults struct { |
80 |
| - Image ImageConfiguration `yaml:"image" json:"image"` |
81 |
| - CPU ResourceConfiguration `yaml:"cpu" json:"cpu"` |
82 |
| - Memory ResourceConfiguration `yaml:"memory" json:"memory"` |
83 |
| - WorkspaceVolume WorkspaceVolumeConfiguration `yaml:"workspaceVolume" json:"workspaceVolume"` |
84 |
| - DataVolumes DataVolumesConfiguration `yaml:"dataVolumes" json:"dataVolumes"` |
85 |
| - GPUs GPUConfiguration `yaml:"gpus" json:"gpus"` |
86 |
| - SharedMemory SharedMemoryConfiguration `yaml:"shm" json:"shm"` |
87 |
| - Configurations ConfigurationsConfiguration `yaml:"configurations" json:"configurations"` |
| 100 | +type ImageGroup struct { |
| 101 | + Value string `yaml:"value" json:"value"` |
| 102 | + Options []string `yaml:"options" json:"options"` |
| 103 | +} |
| 104 | + |
| 105 | +type Shm struct { |
| 106 | + Value bool `yaml:"value" json:"value"` |
| 107 | + ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 108 | +} |
| 109 | + |
| 110 | +type TolerationGroup struct { |
| 111 | + Value string `yaml:"value" json:"value"` |
| 112 | + Options []TolerationGroupOption `yaml:"options" json:"options"` |
| 113 | + ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
| 114 | +} |
| 115 | + |
| 116 | +type TolerationGroupOption struct { |
| 117 | + GroupKey string `yaml:"groupKey" json:"groupKey"` |
| 118 | + DisplayName string `yaml:"displayName" json:"displayName"` |
| 119 | + Tolerations []corev1.Toleration `yaml:"tolerations" json:"tolerations"` |
| 120 | +} |
| 121 | + |
| 122 | +type WorkspaceVolume struct { |
| 123 | + Value ValueValue `yaml:"value" json:"value"` |
| 124 | + ReadOnly bool `yaml:"readOnly" json:"readOnly"` |
88 | 125 | }
|
89 | 126 |
|
90 |
| -// Configuration Struct. |
91 | 127 | type Configuration struct {
|
92 | 128 | SpawnerFormDefaults SpawnerFormDefaults `yaml:"spawnerFormDefaults" json:"spawnerFormDefaults"`
|
93 | 129 | }
|
94 | 130 |
|
95 | 131 | type configresponse struct {
|
96 |
| - APIResponse |
| 132 | + APIResponseBase |
97 | 133 | Config SpawnerFormDefaults `json:"config"`
|
98 | 134 | }
|
99 | 135 |
|
100 | 136 | func (s *server) GetConfig(w http.ResponseWriter, r *http.Request) {
|
101 |
| - s.respond(w, r, configresponse{ |
102 |
| - APIResponse: APIResponse{ |
| 137 | + s.respond(w, r, &configresponse{ |
| 138 | + APIResponseBase: APIResponseBase{ |
103 | 139 | Success: true,
|
| 140 | + Status: http.StatusOK, |
104 | 141 | },
|
105 | 142 | Config: s.Config.SpawnerFormDefaults,
|
106 | 143 | })
|
|
0 commit comments