()
| 68 | } |
| 69 | |
| 70 | func (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. |
| 101 | func (i InstallMode) CheckCompatibility(csv *v1alpha1.ClusterServiceVersion, operatorNamespace string) error { |
no outgoing calls
no test coverage detected