MCPcopy
hub / github.com/operator-framework/operator-sdk / Validate

Method Validate

internal/olm/operator/install_mode.go:70–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68}
69
70func (i InstallMode) Validate() error {
71 switch i.InstallModeType {
72 case v1alpha1.InstallModeTypeAllNamespaces, v1alpha1.InstallModeTypeOwnNamespace:
73 if len(i.TargetNamespaces) != 0 {
74 return fmt.Errorf("install mode %q must have zero target namespaces", i.InstallModeType)
75 }
76 case v1alpha1.InstallModeTypeSingleNamespace:
77 if len(i.TargetNamespaces) != 1 {
78 return fmt.Errorf("install mode %q must have exactly one target namespace", i.InstallModeType)
79 }
80 case v1alpha1.InstallModeTypeMultiNamespace:
81 if len(i.TargetNamespaces) == 0 {
82 return fmt.Errorf("install mode %q must have at least one target namespace", i.InstallModeType)
83 }
84 case "":
85 if len(i.TargetNamespaces) != 0 {
86 return fmt.Errorf("target namespaces defined without type")
87 }
88 default:
89 return fmt.Errorf("unknown install mode type")
90 }
91 for _, ns := range i.TargetNamespaces {
92 errs := validation.IsDNS1123Label(ns)
93 if len(errs) > 0 {
94 return fmt.Errorf("invalid target namespace %q: %v", ns, strings.Join(errs, ", "))
95 }
96 }
97 return nil
98}
99
100// CheckCompatibility checks if an InstallMode is compatible with the operator's namespace and is supported by csv.
101func (i InstallMode) CheckCompatibility(csv *v1alpha1.ClusterServiceVersion, operatorNamespace string) error {

Callers 7

SetMethod · 0.95
ValidateBundleContentFunction · 0.45
runMethod · 0.45
InjectResourceMethod · 0.45
BundleValidationTestFunction · 0.45
validateFunction · 0.45
validatePackageManifestFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected