|
9 | 9 |
|
10 | 10 | "github.com/operator-framework/api/pkg/operators/v1alpha1"
|
11 | 11 | crdlib "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/crd"
|
12 |
| - index "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/index" |
13 | 12 | "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
|
14 | 13 | errorwrap "github.com/pkg/errors"
|
15 | 14 | logger "github.com/sirupsen/logrus"
|
@@ -127,22 +126,9 @@ func (b *builder) NewCRDV1Step(client apiextensionsv1client.ApiextensionsV1Inter
|
127 | 126 | _, createError := client.CustomResourceDefinitions().Create(context.TODO(), crd, metav1.CreateOptions{})
|
128 | 127 | if k8serrors.IsAlreadyExists(createError) {
|
129 | 128 | currentCRD, _ := client.CustomResourceDefinitions().Get(context.TODO(), crd.GetName(), metav1.GetOptions{})
|
130 |
| - // Verify CRD ownership, only attempt to update if |
131 |
| - // CRD has only one owner |
132 |
| - // Example: provided=database.coreos.com/v1alpha1/EtcdCluster |
133 |
| - matchedCSV, err := index.V1CRDProviderNames(b.csvToProvidedAPIs, crd) |
134 |
| - if err != nil { |
135 |
| - return v1alpha1.StepStatusUnknown, errorwrap.Wrapf(err, "error find matched CSV: %s", step.Resource.Name) |
136 |
| - } |
137 | 129 | crd.SetResourceVersion(currentCRD.GetResourceVersion())
|
138 |
| - if len(matchedCSV) == 1 { |
139 |
| - logger.Debugf("Found one owner for CRD %v", crd) |
140 |
| - } else if len(matchedCSV) > 1 { |
141 |
| - logger.Debugf("Found multiple owners for CRD %v", crd) |
142 |
| - |
143 |
| - if err = validateV1CRDCompatibility(b.dynamicClient, currentCRD, crd); err != nil { |
144 |
| - return v1alpha1.StepStatusUnknown, errorwrap.Wrapf(err, "error validating existing CRs against new CRD's schema: %s", step.Resource.Name) |
145 |
| - } |
| 130 | + if err = validateV1CRDCompatibility(b.dynamicClient, currentCRD, crd); err != nil { |
| 131 | + return v1alpha1.StepStatusUnknown, errorwrap.Wrapf(err, "error validating existing CRs against new CRD's schema: %s", step.Resource.Name) |
146 | 132 | }
|
147 | 133 |
|
148 | 134 | // check to see if stored versions changed and whether the upgrade could cause potential data loss
|
@@ -215,22 +201,10 @@ func (b *builder) NewCRDV1Beta1Step(client apiextensionsv1beta1client.Apiextensi
|
215 | 201 | _, createError := client.CustomResourceDefinitions().Create(context.TODO(), crd, metav1.CreateOptions{})
|
216 | 202 | if k8serrors.IsAlreadyExists(createError) {
|
217 | 203 | currentCRD, _ := client.CustomResourceDefinitions().Get(context.TODO(), crd.GetName(), metav1.GetOptions{})
|
218 |
| - // Verify CRD ownership, only attempt to update if |
219 |
| - // CRD has only one owner |
220 |
| - // Example: provided=database.coreos.com/v1alpha1/EtcdCluster |
221 |
| - matchedCSV, err := index.V1Beta1CRDProviderNames(b.csvToProvidedAPIs, crd) |
222 |
| - if err != nil { |
223 |
| - return v1alpha1.StepStatusUnknown, errorwrap.Wrapf(err, "error find matched CSV: %s", step.Resource.Name) |
224 |
| - } |
225 | 204 | crd.SetResourceVersion(currentCRD.GetResourceVersion())
|
226 |
| - if len(matchedCSV) == 1 { |
227 |
| - logger.Debugf("Found one owner for CRD %v", crd) |
228 |
| - } else if len(matchedCSV) > 1 { |
229 |
| - logger.Debugf("Found multiple owners for CRD %v", crd) |
230 | 205 |
|
231 |
| - if err = validateV1Beta1CRDCompatibility(b.dynamicClient, currentCRD, crd); err != nil { |
232 |
| - return v1alpha1.StepStatusUnknown, errorwrap.Wrapf(err, "error validating existing CRs against new CRD's schema: %s", step.Resource.Name) |
233 |
| - } |
| 206 | + if err = validateV1Beta1CRDCompatibility(b.dynamicClient, currentCRD, crd); err != nil { |
| 207 | + return v1alpha1.StepStatusUnknown, errorwrap.Wrapf(err, "error validating existing CRs against new CRD's schema: %s", step.Resource.Name) |
234 | 208 | }
|
235 | 209 |
|
236 | 210 | // check to see if stored versions changed and whether the upgrade could cause potential data loss
|
|
0 commit comments