Skip to content

Commit f399e7e

Browse files
added labels to serviceSpec (#202)
1 parent 64cfcba commit f399e7e

File tree

6 files changed

+24
-4
lines changed

6 files changed

+24
-4
lines changed

api/v1alpha1/dragonfly_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ type ServiceSpec struct {
145145
// +optional
146146
// +kubebuilder:validation:Optional
147147
Annotations map[string]string `json:"annotations,omitempty"`
148+
149+
// (Optional) Dragonfly Service Labels
150+
// +optional
151+
// +kubebuilder:validation:Optional
152+
Labels map[string]string `json:"labels,omitempty"`
148153
}
149154

150155
type Snapshot struct {

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/dragonflydb.io_dragonflies.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.1
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.13.0
87
name: dragonflies.dragonflydb.io
98
spec:
109
group: dragonflydb.io
@@ -1130,6 +1129,11 @@ spec:
11301129
type: string
11311130
description: (Optional) Dragonfly Service Annotations
11321131
type: object
1132+
labels:
1133+
additionalProperties:
1134+
type: string
1135+
description: (Optional) Dragonfly Service Labels
1136+
type: object
11331137
name:
11341138
description: (Optional) Dragonfly Service name
11351139
type: string

config/rbac/role.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
5-
creationTimestamp: null
65
name: manager-role
76
rules:
87
- apiGroups:

e2e/dragonfly_controller_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,14 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, FlakeAttempts(3), func()
502502
newAnnotations := map[string]string{
503503
"service-annotaions": "true",
504504
}
505+
newLabels := map[string]string{
506+
"service-labels": "true",
507+
}
505508
df.Spec.ServiceSpec = &resourcesv1.ServiceSpec{
506509
Type: corev1.ServiceTypeLoadBalancer,
507510
Name: "test-svc",
508511
Annotations: newAnnotations,
512+
Labels: newLabels,
509513
}
510514

511515
err = k8sClient.Update(ctx, &df)
@@ -526,6 +530,7 @@ var _ = Describe("Dragonfly Lifecycle tests", Ordered, FlakeAttempts(3), func()
526530

527531
Expect(svc.Spec.Type).To(Equal(corev1.ServiceTypeLoadBalancer))
528532
Expect(svc.Annotations).To(Equal(newAnnotations))
533+
Expect(svc.Labels).To(Equal(newLabels))
529534
})
530535

531536
It("Cleanup", func() {

internal/resources/resources.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ func GetDragonflyResources(ctx context.Context, df *resourcesv1.Dragonfly) ([]cl
384384
if df.Spec.ServiceSpec != nil {
385385
service.Spec.Type = df.Spec.ServiceSpec.Type
386386
service.Annotations = df.Spec.ServiceSpec.Annotations
387+
service.Labels = df.Spec.ServiceSpec.Labels
387388
}
388389
if df.Spec.MemcachedPort != 0 {
389390
service.Spec.Ports = append(service.Spec.Ports, corev1.ServicePort{

0 commit comments

Comments
 (0)