Skip to content

Commit 7249333

Browse files
committed
feat: add namespace for configmap resource
1 parent cea9552 commit 7249333

File tree

6 files changed

+54
-8
lines changed

6 files changed

+54
-8
lines changed

workspaces/backend/api/suite_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func TestAPI(t *testing.T) {
6565
RunSpecs(t, "API Suite")
6666
}
6767

68+
const namespaceName = "default"
69+
6870
var _ = BeforeSuite(func() {
6971
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
7072
ctx, cancel = context.WithCancel(context.Background())
@@ -177,8 +179,9 @@ func NewExampleWorkspaceKind(name string) *kubefloworgv1beta1.WorkspaceKind {
177179
},
178180
Logo: kubefloworgv1beta1.WorkspaceKindIcon{
179181
ConfigMap: &kubefloworgv1beta1.WorkspaceKindConfigMap{
180-
Name: "my-logos",
181-
Key: "apple-touch-icon-152x152.png",
182+
Name: "my-logos",
183+
Namespace: namespaceName,
184+
Key: "apple-touch-icon-152x152.png",
182185
},
183186
},
184187
},

workspaces/controller/api/v1beta1/workspacekind_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,21 @@ type WorkspaceKindIcon struct {
8989
}
9090

9191
type WorkspaceKindConfigMap struct {
92+
93+
//+kubebuilder:validation:MinLength:=1
94+
//+kubebuilder:validation:MaxLength:=253
95+
//+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
9296
//+kubebuilder:example="my-logos"
9397
Name string `json:"name"`
9498

99+
//+kubebuilder:validation:MinLength:=1
100+
//+kubebuilder:validation:MaxLength:=63
101+
//+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
102+
Namespace string `json:"namespace"`
103+
104+
//+kubebuilder:validation:MinLength:=1
105+
//+kubebuilder:validation:MaxLength:=253
106+
//+kubebuilder:validation:Pattern:=^[-._a-zA-Z0-9]+$
95107
//+kubebuilder:example="apple-touch-icon-152x152.png"
96108
Key string `json:"key"`
97109
}

workspaces/controller/config/crd/bases/kubeflow.org_workspacekinds.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4273,13 +4273,25 @@ spec:
42734273
properties:
42744274
key:
42754275
example: apple-touch-icon-152x152.png
4276+
maxLength: 253
4277+
minLength: 1
4278+
pattern: ^[-._a-zA-Z0-9]+$
42764279
type: string
42774280
name:
42784281
example: my-logos
4282+
maxLength: 253
4283+
minLength: 1
4284+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
4285+
type: string
4286+
namespace:
4287+
maxLength: 63
4288+
minLength: 1
4289+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
42794290
type: string
42804291
required:
42814292
- key
42824293
- name
4294+
- namespace
42834295
type: object
42844296
url:
42854297
example: https://jupyter.org/assets/favicons/apple-touch-icon-152x152.png
@@ -4298,13 +4310,25 @@ spec:
42984310
properties:
42994311
key:
43004312
example: apple-touch-icon-152x152.png
4313+
maxLength: 253
4314+
minLength: 1
4315+
pattern: ^[-._a-zA-Z0-9]+$
43014316
type: string
43024317
name:
43034318
example: my-logos
4319+
maxLength: 253
4320+
minLength: 1
4321+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
4322+
type: string
4323+
namespace:
4324+
maxLength: 63
4325+
minLength: 1
4326+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
43044327
type: string
43054328
required:
43064329
- key
43074330
- name
4331+
- namespace
43084332
type: object
43094333
url:
43104334
example: https://jupyter.org/assets/favicons/apple-touch-icon-152x152.png

workspaces/controller/internal/controller/suite_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ var (
5858
cancel context.CancelFunc
5959
)
6060

61+
const namespaceName = "default"
62+
6163
func TestControllers(t *testing.T) {
6264
RegisterFailHandler(Fail)
6365

@@ -192,8 +194,9 @@ func NewExampleWorkspaceKind1(name string) *kubefloworgv1beta1.WorkspaceKind {
192194
},
193195
Logo: kubefloworgv1beta1.WorkspaceKindIcon{
194196
ConfigMap: &kubefloworgv1beta1.WorkspaceKindConfigMap{
195-
Name: "my-logos",
196-
Key: "apple-touch-icon-152x152.png",
197+
Name: "my-logos",
198+
Namespace: namespaceName,
199+
Key: "apple-touch-icon-152x152.png",
197200
},
198201
},
199202
},

workspaces/controller/internal/controller/workspacekind_controller_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ var _ = Describe("WorkspaceKind Controller", func() {
118118
newWorkspaceKind.Spec.Spawner.Icon = kubefloworgv1beta1.WorkspaceKindIcon{
119119
Url: ptr.To("https://example.com/icon.png"),
120120
ConfigMap: &kubefloworgv1beta1.WorkspaceKindConfigMap{
121-
Name: "my-logos",
122-
Key: "icon.png",
121+
Name: "my-logos",
122+
Namespace: namespaceName,
123+
Key: "icon.png",
123124
},
124125
}
125126
Expect(k8sClient.Patch(ctx, newWorkspaceKind, patch)).NotTo(Succeed())

workspaces/controller/internal/webhook/suite_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ var (
6363
cancel context.CancelFunc
6464
)
6565

66+
const namespaceName = "default"
67+
6668
func TestAPIs(t *testing.T) {
6769
RegisterFailHandler(Fail)
6870

@@ -186,8 +188,9 @@ func NewExampleWorkspaceKind(name string) *kubefloworgv1beta1.WorkspaceKind {
186188
},
187189
Logo: kubefloworgv1beta1.WorkspaceKindIcon{
188190
ConfigMap: &kubefloworgv1beta1.WorkspaceKindConfigMap{
189-
Name: "my-logos",
190-
Key: "apple-touch-icon-152x152.png",
191+
Name: "my-logos",
192+
Namespace: namespaceName,
193+
Key: "apple-touch-icon-152x152.png",
191194
},
192195
},
193196
},

0 commit comments

Comments
 (0)