@@ -3,11 +3,12 @@ package resourceapply
33import (
44 "context"
55 "fmt"
6- clocktesting "k8s.io/utils/clock/testing"
76 "strings"
87 "testing"
98 "time"
109
10+ clocktesting "k8s.io/utils/clock/testing"
11+
1112 "github.com/davecgh/go-spew/spew"
1213 "github.com/openshift/library-go/pkg/operator/events"
1314 v1 "k8s.io/api/core/v1"
@@ -622,6 +623,45 @@ func TestApplyCSIDriver(t *testing.T) {
622623 }
623624 },
624625 },
626+ {
627+ name : "exempt label with missing labels on original object" ,
628+ existing : []* storagev1.CSIDriver {
629+ {
630+ ObjectMeta : metav1.ObjectMeta {
631+ Name : "foo" ,
632+ Annotations : map [string ]string {"my.csi.driver/foo" : "bar" },
633+ Labels : map [string ]string {
634+ csiInlineVolProfileLabel : "restricted" ,
635+ },
636+ },
637+ Spec : storagev1.CSIDriverSpec {
638+ VolumeLifecycleModes : []storagev1.VolumeLifecycleMode {
639+ storagev1 .VolumeLifecyclePersistent ,
640+ },
641+ },
642+ },
643+ },
644+ input : & storagev1.CSIDriver {
645+ ObjectMeta : metav1.ObjectMeta {
646+ Name : "foo" ,
647+ Annotations : map [string ]string {"my.csi.driver/foo" : "bar" },
648+ },
649+ Spec : storagev1.CSIDriverSpec {
650+ VolumeLifecycleModes : []storagev1.VolumeLifecycleMode {
651+ storagev1 .VolumeLifecyclePersistent ,
652+ },
653+ },
654+ },
655+ expectedModified : false ,
656+ verifyActions : func (actions []clienttesting.Action , t * testing.T ) {
657+ if len (actions ) != 1 {
658+ t .Fatal (spew .Sdump (actions ))
659+ }
660+ if ! actions [0 ].Matches ("get" , "csidrivers" ) || actions [0 ].(clienttesting.GetAction ).GetName () != "foo" {
661+ t .Error (spew .Sdump (actions ))
662+ }
663+ },
664+ },
625665 {
626666 name : "exempt label with differing value should not be overwritten during update" ,
627667 existing : []* storagev1.CSIDriver {
0 commit comments