-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.go
171 lines (145 loc) · 5.82 KB
/
config.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package main
import (
"net/http"
corev1 "k8s.io/api/core/v1"
)
type SpawnerFormDefaults struct {
Image Image `yaml:"image" json:"image"`
ImageGroupOne ImageGroup `yaml:"imageGroupOne" json:"imageGroupOne"`
ImageGroupTwo ImageGroup `yaml:"imageGroupTwo" json:"imageGroupTwo"`
ImageGroupThree ImageGroup `yaml:"imageGroupThree" json:"imageGroupThree"`
AllowCustomImage bool `yaml:"allowCustomImage" json:"allowCustomImage"`
ImagePullPolicy ImagePullPolicy `yaml:"imagePullPolicy" json:"imagePullPolicy"`
CPU CPU `yaml:"cpu" json:"cpu"`
Memory CPU `yaml:"memory" json:"memory"`
WorkspaceVolume WorkspaceVolume `yaml:"workspaceVolume" json:"workspaceVolume"`
DataVolumes DataVolumes `yaml:"dataVolumes" json:"dataVolumes"`
GPUs GPUs `yaml:"gpus" json:"gpus"`
Shm Shm `yaml:"shm" json:"shm"`
Configurations Configurations `yaml:"configurations" json:"configurations"`
AffinityConfig AffinityConfig `yaml:"affinityConfig" json:"affinityConfig"`
TolerationGroup TolerationGroup `yaml:"tolerationGroup" json:"tolerationGroup"`
HideRegistry bool `yaml:"hideRegistry" json:"hideRegistry"`
HideTag bool `yaml:"hideTag" json:"hideTag"`
}
type AffinityConfig struct {
Value string `yaml:"value" json:"value"`
Options []AffinityConfigOption `yaml:"options" json:"options"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}
type AffinityConfigOption struct {
ConfigKey string `yaml:"configKey" json:"configKey"`
DisplayName string `yaml:"displayName" json:"displayName"`
Affinity corev1.Affinity `yaml:"affinity" json:"affinity"`
}
type LabelSelectorMatchExpression struct {
Key string `yaml:"key" json:"key"`
Operator string `yaml:"operator" json:"operator"`
}
type CPU struct {
Value string `yaml:"value" json:"value"`
GpuDefault string `yaml:"gpuDefault" json:"gpuDefault"`
LimitFactor string `yaml:"limitFactor" json:"limitFactor"`
LimitValue string `yaml:"limitValue" json:"limitValue"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}
type Configurations struct {
Value []string `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}
type DataVolumes struct {
Value []ValueElement `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}
type ValueElement struct {
Value VolumeValues `yaml:"value" json:"value"`
}
// Structs for the yaml versions of definitions, minimalistic as it is just a default
// can't re-use structs from go since this is yaml and not json
type VolumeValues struct {
Mount string `yaml:"mount" json:"mount"`
NewPvc NewPvcYaml `yaml:"newPvc" json:"newPvc"`
}
type NewPvcMetadataYaml struct {
Name string `yaml:"name" json:"name"`
}
type NewPvcRequestsYaml struct {
Storage string `yaml:"storage" json:"storage"`
}
type NewPvcResourcesYaml struct {
Requests NewPvcRequestsYaml `yaml:"requests" json:"requests"`
}
type NewPvcSpecYaml struct {
Resources NewPvcResourcesYaml `yaml:"resources" json:"resources"`
AccessModes []corev1.PersistentVolumeAccessMode `yaml:"accessModes" json:"accessModes"`
}
type NewPvcYaml struct {
Metadata NewPvcMetadataYaml `yaml:"metadata" json:"metadata"`
Spec NewPvcSpecYaml `yaml:"spec" json:"spec"`
} // last struct for yaml versions
type ImagePullPolicy struct {
Value string `yaml:"value" json:"value"`
}
type GPUs struct {
Value GpusValue `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}
type GpusValue struct {
Num string `yaml:"num" json:"num"`
Vendors []Vendor `yaml:"vendors" json:"vendors"`
Vendor string `yaml:"vendor" json:"vendor"`
}
type Vendor struct {
LimitsKey string `yaml:"limitsKey" json:"limitsKey"`
UIName string `yaml:"uiName" json:"uiName"`
}
type Image struct {
Value string `yaml:"value" json:"value"`
Options []string `yaml:"options" json:"options"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
HideRegistry bool `yaml:"hideRegistry" json:"hideRegistry"`
HideVersion bool `yaml:"hideVersion" json:"hideVersion"`
}
type ImageGroup struct {
DisabledMessage map[string]string `yaml:"disabledMessage" json:"disabledMessage,omitempty"`
EnabledCondition *EnabledCondition `yaml:"enabledCondition" json:"enabledCondition,omitempty"`
Value string `yaml:"value" json:"value"`
Options []string `yaml:"options" json:"options"`
}
type EnabledCondition struct {
Labels map[string]string `yaml:"labels" json:"labels,omitempty"`
}
type Shm struct {
Value bool `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}
type TolerationGroup struct {
Value string `yaml:"value" json:"value"`
Options []TolerationGroupOption `yaml:"options" json:"options"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}
type TolerationGroupOption struct {
GroupKey string `yaml:"groupKey" json:"groupKey"`
DisplayName string `yaml:"displayName" json:"displayName"`
Tolerations []corev1.Toleration `yaml:"tolerations" json:"tolerations"`
}
type WorkspaceVolume struct {
Value VolumeValues `yaml:"value" json:"value"`
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
}
type Configuration struct {
SpawnerFormDefaults SpawnerFormDefaults `yaml:"spawnerFormDefaults" json:"spawnerFormDefaults"`
}
type configresponse struct {
APIResponseBase
Config SpawnerFormDefaults `json:"config"`
}
func (s *server) GetConfig(w http.ResponseWriter, r *http.Request) {
s.respond(w, r, &configresponse{
APIResponseBase: APIResponseBase{
Success: true,
Status: http.StatusOK,
},
Config: s.Config.SpawnerFormDefaults,
})
}