Skip to content

Commit 863a996

Browse files
Zachary Seguinsylus
Zachary Seguin
andauthored
feat: Update for Kubeflow v1.3.0 (#67)
* feat: Update for Kubeflow v1.3.0 Implement the start/stop functionality * feat(config): Switch to yaml to go generation Signed-off-by: William Hearn <sylus1984@gmail.com> * feat: Update create notebok for v1.3.0 Switch to https://github.com/StatCan/kubeflow-apis for Kubeflow resources * fix(workflow): Update go to 1.17.7 Co-authored-by: William Hearn <sylus1984@gmail.com>
1 parent dcfba4c commit 863a996

16 files changed

+1175
-417
lines changed

.github/workflows/build.yml

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020
- name: Checkout
2121
uses: actions/checkout@v2
2222

23+
- uses: actions/setup-go@v2
24+
with:
25+
go-version: '1.17.7'
26+
2327
- name: Gather dependencies
2428
run: |
2529
mkdir -p ${GITHUB_WORKSPACE}/bin/

Taskfile.yml

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ tasks:
5353
check:
5454
desc: Check for problems associated with the project
5555
deps:
56-
- task: go:lint
5756
- task: go:vet
5857
- task: go:test
5958

access.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ func (s *server) checkAccess(subjectAccessReviewTemplate authorizationv1.Subject
4949
user := r.URL.User.Username()
5050
if user == "" {
5151
log.Printf("no user found")
52-
s.respond(w, r, APIResponse{
52+
s.respond(w, r, &APIResponseBase{
5353
Success: false,
54+
Status: http.StatusNotFound,
5455
Log: "no user found",
5556
})
5657
return
@@ -77,8 +78,9 @@ func (s *server) checkAccess(subjectAccessReviewTemplate authorizationv1.Subject
7778

7879
log.Println(msg)
7980

80-
s.respond(w, r, APIResponse{
81+
s.respond(w, r, &APIResponseBase{
8182
Success: false,
83+
Status: http.StatusForbidden,
8284
Log: msg,
8385
})
8486
return

config.go

+98-61
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,143 @@
11
package main
22

3-
import "net/http"
3+
import (
4+
"net/http"
45

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"`
924
}
1025

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"`
1530
}
1631

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"`
2136
}
2237

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"`
2841
}
2942

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"`
3447
}
3548

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"`
3961
}
4062

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"`
4970
}
5071

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"`
5574
}
5675

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"`
6179
}
6280

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"`
6785
}
6886

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 {
7193
Value string `yaml:"value" json:"value"`
7294
Options []string `yaml:"options" json:"options"`
7395
ReadOnly bool `yaml:"readOnly" json:"readOnly"`
7496
HideRegistry bool `yaml:"hideRegistry" json:"hideRegistry"`
7597
HideVersion bool `yaml:"hideVersion" json:"hideVersion"`
7698
}
7799

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"`
88125
}
89126

90-
// Configuration Struct.
91127
type Configuration struct {
92128
SpawnerFormDefaults SpawnerFormDefaults `yaml:"spawnerFormDefaults" json:"spawnerFormDefaults"`
93129
}
94130

95131
type configresponse struct {
96-
APIResponse
132+
APIResponseBase
97133
Config SpawnerFormDefaults `json:"config"`
98134
}
99135

100136
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{
103139
Success: true,
140+
Status: http.StatusOK,
104141
},
105142
Config: s.Config.SpawnerFormDefaults,
106143
})

go.mod

+50-35
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,57 @@
11
module github.com/StatCan/jupyter-apis
22

3-
go 1.14
3+
go 1.17
44

55
require (
6-
github.com/Azure/go-autorest/autorest v0.11.4 // indirect
7-
github.com/Azure/go-autorest/autorest/adal v0.9.2 // indirect
8-
github.com/StatCan/kubeflow-controller v0.0.0-20200811133651-33215007413e
9-
github.com/andanhm/go-prettytime v1.0.0
10-
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
11-
github.com/golang/protobuf v1.4.2 // indirect
12-
github.com/google/gofuzz v1.2.0 // indirect
13-
github.com/gorilla/handlers v1.4.2
14-
github.com/gorilla/mux v1.7.4
15-
github.com/hashicorp/golang-lru v0.5.4 // indirect
16-
github.com/imdario/mergo v0.3.10 // indirect
17-
github.com/json-iterator/go v1.1.10 // indirect
18-
github.com/kr/pretty v0.2.0 // indirect
19-
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de // indirect
20-
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc // indirect
21-
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
22-
golang.org/x/sys v0.0.0-20200817155316-9781c653f443 // indirect
23-
golang.org/x/text v0.3.3 // indirect
24-
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
25-
google.golang.org/appengine v1.6.6 // indirect
26-
google.golang.org/protobuf v1.25.0 // indirect
27-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
6+
github.com/StatCan/kubeflow-apis v0.0.0-20220217170523-72ec9dc9b637
7+
github.com/andanhm/go-prettytime v1.1.0
8+
github.com/gorilla/handlers v1.5.1
9+
github.com/gorilla/mux v1.8.0
2810
gopkg.in/inf.v0 v0.9.1
29-
gopkg.in/yaml.v2 v2.3.0
30-
k8s.io/api v0.18.6
31-
k8s.io/apimachinery v0.18.8
32-
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
33-
k8s.io/utils v0.0.0-20200815180417-3bc9d57fc792 // indirect
11+
gopkg.in/yaml.v2 v2.4.0
12+
k8s.io/api v0.23.3
13+
k8s.io/apimachinery v0.23.3
14+
k8s.io/client-go v0.23.3
3415
)
3516

36-
replace k8s.io/client-go => k8s.io/client-go v0.18.6
37-
38-
replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.6
39-
40-
replace sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.6.2
41-
42-
replace github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.0
17+
require (
18+
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
19+
github.com/Azure/go-autorest/autorest v0.11.18 // indirect
20+
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
21+
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
22+
github.com/Azure/go-autorest/logger v0.2.1 // indirect
23+
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
24+
github.com/davecgh/go-spew v1.1.1 // indirect
25+
github.com/felixge/httpsnoop v1.0.1 // indirect
26+
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
27+
github.com/fsnotify/fsnotify v1.5.1 // indirect
28+
github.com/go-logr/logr v1.2.0 // indirect
29+
github.com/gogo/protobuf v1.3.2 // indirect
30+
github.com/golang/protobuf v1.5.2 // indirect
31+
github.com/google/go-cmp v0.5.5 // indirect
32+
github.com/google/gofuzz v1.1.0 // indirect
33+
github.com/googleapis/gnostic v0.5.5 // indirect
34+
github.com/imdario/mergo v0.3.12 // indirect
35+
github.com/json-iterator/go v1.1.12 // indirect
36+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
37+
github.com/modern-go/reflect2 v1.0.2 // indirect
38+
github.com/onsi/ginkgo v1.16.5 // indirect
39+
github.com/onsi/gomega v1.17.0 // indirect
40+
github.com/spf13/pflag v1.0.5 // indirect
41+
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
42+
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
43+
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
44+
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect
45+
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
46+
golang.org/x/text v0.3.7 // indirect
47+
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
48+
google.golang.org/appengine v1.6.7 // indirect
49+
google.golang.org/protobuf v1.27.1 // indirect
50+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
51+
k8s.io/klog/v2 v2.30.0 // indirect
52+
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
53+
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
54+
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
55+
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
56+
sigs.k8s.io/yaml v1.3.0 // indirect
57+
)

0 commit comments

Comments
 (0)