Skip to content

Commit 15ed72a

Browse files
hervedombyaZiyangLinScality
authored andcommitted
basic crd for ScalityUIComponent
1 parent 73c1fd0 commit 15ed72a

15 files changed

+440
-2
lines changed

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,13 @@ resources:
2020
kind: ScalityUI
2121
path: github.com/scality/ui-operator/api/v1alpha1
2222
version: v1alpha1
23+
- api:
24+
crdVersion: v1
25+
namespaced: true
26+
controller: true
27+
domain: scality.com
28+
group: ui
29+
kind: ScalityUIComponent
30+
path: github.com/scality/ui-operator/api/v1alpha1
31+
version: v1alpha1
2332
version: "3"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// ScalityUIComponentSpec defines the desired state of ScalityUIComponent
27+
type ScalityUIComponentSpec struct {
28+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29+
// Important: Run "make" to regenerate code after modifying this file
30+
Image string `json:"image"`
31+
}
32+
33+
// ScalityUIComponentStatus defines the observed state of ScalityUIComponent
34+
type ScalityUIComponentStatus struct {
35+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
36+
// Important: Run "make" to regenerate code after modifying this file
37+
}
38+
39+
// +kubebuilder:object:root=true
40+
// +kubebuilder:subresource:status
41+
42+
// ScalityUIComponent is the Schema for the scalityuicomponents API
43+
type ScalityUIComponent struct {
44+
metav1.TypeMeta `json:",inline"`
45+
metav1.ObjectMeta `json:"metadata,omitempty"`
46+
47+
Spec ScalityUIComponentSpec `json:"spec,omitempty"`
48+
Status ScalityUIComponentStatus `json:"status,omitempty"`
49+
}
50+
51+
// +kubebuilder:object:root=true
52+
53+
// ScalityUIComponentList contains a list of ScalityUIComponent
54+
type ScalityUIComponentList struct {
55+
metav1.TypeMeta `json:",inline"`
56+
metav1.ListMeta `json:"metadata,omitempty"`
57+
Items []ScalityUIComponent `json:"items"`
58+
}
59+
60+
func init() {
61+
SchemeBuilder.Register(&ScalityUIComponent{}, &ScalityUIComponentList{})
62+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ func main() {
152152
setupLog.Error(err, "unable to create controller", "controller", "ScalityUI")
153153
os.Exit(1)
154154
}
155+
if err = (&controller.ScalityUIComponentReconciler{
156+
Client: mgr.GetClient(),
157+
Scheme: mgr.GetScheme(),
158+
}).SetupWithManager(mgr); err != nil {
159+
setupLog.Error(err, "unable to create controller", "controller", "ScalityUIComponent")
160+
os.Exit(1)
161+
}
155162
// +kubebuilder:scaffold:builder
156163

157164
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.1
7+
name: scalityuicomponents.ui.scality.com
8+
spec:
9+
group: ui.scality.com
10+
names:
11+
kind: ScalityUIComponent
12+
listKind: ScalityUIComponentList
13+
plural: scalityuicomponents
14+
singular: scalityuicomponent
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: ScalityUIComponent is the Schema for the scalityuicomponents
21+
API
22+
properties:
23+
apiVersion:
24+
description: |-
25+
APIVersion defines the versioned schema of this representation of an object.
26+
Servers should convert recognized schemas to the latest internal value, and
27+
may reject unrecognized values.
28+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
29+
type: string
30+
kind:
31+
description: |-
32+
Kind is a string value representing the REST resource this object represents.
33+
Servers may infer this from the endpoint the client submits requests to.
34+
Cannot be updated.
35+
In CamelCase.
36+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
37+
type: string
38+
metadata:
39+
type: object
40+
spec:
41+
description: ScalityUIComponentSpec defines the desired state of ScalityUIComponent
42+
properties:
43+
image:
44+
description: |-
45+
INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
46+
Important: Run "make" to regenerate code after modifying this file
47+
type: string
48+
required:
49+
- image
50+
type: object
51+
status:
52+
description: ScalityUIComponentStatus defines the observed state of ScalityUIComponent
53+
type: object
54+
type: object
55+
served: true
56+
storage: true
57+
subresources:
58+
status: {}

config/crd/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# It should be run by config/default
44
resources:
55
- bases/ui.scality.com_scalityuis.yaml
6+
- bases/ui.scality.com_scalityuicomponents.yaml
67
# +kubebuilder:scaffold:crdkustomizeresource
78

89
patches:
@@ -13,6 +14,7 @@ patches:
1314
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1415
# patches here are for enabling the CA injection for each CRD
1516
#- path: patches/cainjection_in_scalityuis.yaml
17+
#- path: patches/cainjection_in_scalityuicomponents.yaml
1618
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
1719

1820
# [WEBHOOK] To enable webhook, uncomment the following section

config/rbac/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ resources:
2222
# default, aiding admins in cluster management. Those roles are
2323
# not used by the Project itself. You can comment the following lines
2424
# if you do not want those helpers be installed with your Project.
25+
- scalityuicomponent_editor_role.yaml
26+
- scalityuicomponent_viewer_role.yaml
2527
- scalityui_editor_role.yaml
2628
- scalityui_viewer_role.yaml
2729

config/rbac/role.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ rules:
77
- apiGroups:
88
- ui.scality.com
99
resources:
10+
- scalityuicomponents
1011
- scalityuis
1112
verbs:
1213
- create
@@ -19,12 +20,14 @@ rules:
1920
- apiGroups:
2021
- ui.scality.com
2122
resources:
23+
- scalityuicomponents/finalizers
2224
- scalityuis/finalizers
2325
verbs:
2426
- update
2527
- apiGroups:
2628
- ui.scality.com
2729
resources:
30+
- scalityuicomponents/status
2831
- scalityuis/status
2932
verbs:
3033
- get
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# permissions for end users to edit scalityuicomponents.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: ui-operator
7+
app.kubernetes.io/managed-by: kustomize
8+
name: scalityuicomponent-editor-role
9+
rules:
10+
- apiGroups:
11+
- ui.scality.com
12+
resources:
13+
- scalityuicomponents
14+
verbs:
15+
- create
16+
- delete
17+
- get
18+
- list
19+
- patch
20+
- update
21+
- watch
22+
- apiGroups:
23+
- ui.scality.com
24+
resources:
25+
- scalityuicomponents/status
26+
verbs:
27+
- get
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# permissions for end users to view scalityuicomponents.
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
labels:
6+
app.kubernetes.io/name: ui-operator
7+
app.kubernetes.io/managed-by: kustomize
8+
name: scalityuicomponent-viewer-role
9+
rules:
10+
- apiGroups:
11+
- ui.scality.com
12+
resources:
13+
- scalityuicomponents
14+
verbs:
15+
- get
16+
- list
17+
- watch
18+
- apiGroups:
19+
- ui.scality.com
20+
resources:
21+
- scalityuicomponents/status
22+
verbs:
23+
- get

0 commit comments

Comments
 (0)