Skip to content

Commit f1c3de2

Browse files
authored
Validate service label and annotation absence (minio#2095)
1 parent 010b890 commit f1c3de2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/controller/minio-services.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,18 @@ func (c *Controller) checkMinIOSvc(ctx context.Context, tenant *miniov2.Tenant,
9191

9292
func minioSvcMatchesSpecification(svc *corev1.Service, expectedSvc *corev1.Service) (bool, error) {
9393
// expected labels match
94+
if len(svc.ObjectMeta.Labels) != len(expectedSvc.ObjectMeta.Labels) {
95+
return false, errors.New("service labels don't match")
96+
}
9497
for k, expVal := range expectedSvc.ObjectMeta.Labels {
9598
if value, ok := svc.ObjectMeta.Labels[k]; !ok || value != expVal {
9699
return false, errors.New("service labels don't match")
97100
}
98101
}
99102
// expected annotations match
103+
if len(svc.ObjectMeta.Annotations) != len(expectedSvc.ObjectMeta.Annotations) {
104+
return false, errors.New("service annotations don't match")
105+
}
100106
for k, expVal := range expectedSvc.ObjectMeta.Annotations {
101107
if value, ok := svc.ObjectMeta.Annotations[k]; !ok || value != expVal {
102108
return false, errors.New("service annotations don't match")

0 commit comments

Comments
 (0)