@@ -3,11 +3,12 @@ package resourceapply
3
3
import (
4
4
"context"
5
5
"fmt"
6
- clocktesting "k8s.io/utils/clock/testing"
7
6
"strings"
8
7
"testing"
9
8
"time"
10
9
10
+ clocktesting "k8s.io/utils/clock/testing"
11
+
11
12
"github.com/davecgh/go-spew/spew"
12
13
"github.com/openshift/library-go/pkg/operator/events"
13
14
v1 "k8s.io/api/core/v1"
@@ -622,6 +623,45 @@ func TestApplyCSIDriver(t *testing.T) {
622
623
}
623
624
},
624
625
},
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
+ },
625
665
{
626
666
name : "exempt label with differing value should not be overwritten during update" ,
627
667
existing : []* storagev1.CSIDriver {
0 commit comments