-
Notifications
You must be signed in to change notification settings - Fork 73
/
operatorgroup.go
35 lines (30 loc) · 1.33 KB
/
operatorgroup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package internal
import (
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
operatorsv1alpha2 "github.com/operator-framework/api/pkg/operators/v1alpha2"
"github.com/operator-framework/api/pkg/validation/errors"
interfaces "github.com/operator-framework/api/pkg/validation/interfaces"
)
// OperatorGroupValidator is a validator for OperatorGroup
var OperatorGroupValidator interfaces.Validator = interfaces.ValidatorFunc(validateOperatorGroups)
func validateOperatorGroups(objs ...interface{}) (results []errors.ManifestResult) {
for _, obj := range objs {
switch v := obj.(type) {
case *operatorsv1.OperatorGroup:
results = append(results, validateOperatorGroupV1(v))
case *operatorsv1alpha2.OperatorGroup:
results = append(results, validateOperatorGroupV1Alpha2(v))
}
}
return results
}
func validateOperatorGroupV1Alpha2(operatorGroup *operatorsv1alpha2.OperatorGroup) (result errors.ManifestResult) {
// validate case sensitive annotation names
result.Add(ValidateAnnotationNames(operatorGroup.GetAnnotations(), operatorGroup.GetName())...)
return result
}
func validateOperatorGroupV1(operatorGroup *operatorsv1.OperatorGroup) (result errors.ManifestResult) {
// validate case sensitive annotation names
result.Add(ValidateAnnotationNames(operatorGroup.GetAnnotations(), operatorGroup.GetName())...)
return result
}