Skip to content

Commit

Permalink
Validate service label and annotation absence (#2095)
Browse files Browse the repository at this point in the history
  • Loading branch information
allanrogerr committed May 1, 2024
1 parent 010b890 commit f1c3de2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/controller/minio-services.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,18 @@ func (c *Controller) checkMinIOSvc(ctx context.Context, tenant *miniov2.Tenant,

func minioSvcMatchesSpecification(svc *corev1.Service, expectedSvc *corev1.Service) (bool, error) {
// expected labels match
if len(svc.ObjectMeta.Labels) != len(expectedSvc.ObjectMeta.Labels) {
return false, errors.New("service labels don't match")
}
for k, expVal := range expectedSvc.ObjectMeta.Labels {
if value, ok := svc.ObjectMeta.Labels[k]; !ok || value != expVal {
return false, errors.New("service labels don't match")
}
}
// expected annotations match
if len(svc.ObjectMeta.Annotations) != len(expectedSvc.ObjectMeta.Annotations) {
return false, errors.New("service annotations don't match")
}
for k, expVal := range expectedSvc.ObjectMeta.Annotations {
if value, ok := svc.ObjectMeta.Annotations[k]; !ok || value != expVal {
return false, errors.New("service annotations don't match")
Expand Down

0 comments on commit f1c3de2

Please sign in to comment.