5
5
"fmt"
6
6
"time"
7
7
8
+ "k8s.io/apimachinery/pkg/types"
9
+
8
10
"github.com/blang/semver"
9
11
. "github.com/onsi/ginkgo"
10
12
. "github.com/onsi/gomega"
@@ -15,6 +17,7 @@ import (
15
17
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
16
18
k8serrors "k8s.io/apimachinery/pkg/api/errors"
17
19
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20
+ "sigs.k8s.io/controller-runtime/pkg/client"
18
21
)
19
22
20
23
var _ = Describe ("CRD Versions" , func () {
@@ -304,8 +307,21 @@ var _ = Describe("CRD Versions", func() {
304
307
305
308
// update channel on sub
306
309
sub .Spec .Channel = alphaChannel
307
- _ , err = crc .OperatorsV1alpha1 ().Subscriptions (testNamespace ).Update (context .TODO (), sub , metav1.UpdateOptions {})
308
- Expect (err ).ToNot (HaveOccurred (), "could not update subscription" )
310
+ sub .TypeMeta .APIVersion = "operators.coreos.com/v1alpha1"
311
+ sub .TypeMeta .Kind = "Subscription"
312
+ sub .ManagedFields = []metav1.ManagedFieldsEntry {}
313
+
314
+ // use server-side apply to apply the update to the subscription point to the alpha channel
315
+ forceApply := true
316
+ opts := metav1.PatchOptions {
317
+ Force : & forceApply ,
318
+ FieldManager : "operator-lifecycle-manager-registry-reconciler" ,
319
+ }
320
+ newSub , err := client .Apply .Data (sub )
321
+ Expect (err ).ToNot (HaveOccurred (), "could not serialize updated subscription to bytes" )
322
+
323
+ _ , err = crc .OperatorsV1alpha1 ().Subscriptions (testNamespace ).Patch (context .TODO (), sub .GetName (), types .ApplyPatchType , newSub , opts )
324
+ Expect (err ).ToNot (HaveOccurred (), "could not patch subscription with updated channel" )
309
325
310
326
subscriptionAtLatestWithDifferentInstallPlan := func (v * operatorsv1alpha1.Subscription ) bool {
311
327
return subscriptionStateAtLatestChecker (v ) && v .Status .InstallPlanRef != nil && v .Status .InstallPlanRef .Name != fetchedInstallPlan .Name
0 commit comments