@@ -121,6 +121,65 @@ func TestCopyToNamespace(t *testing.T) {
121121 },
122122 },
123123 },
124+ {
125+ Name : "component labels are stripped before copy" ,
126+ Namespace : "bar" ,
127+ Original : & v1alpha1.ClusterServiceVersion {
128+ ObjectMeta : metav1.ObjectMeta {
129+ Name : "name" ,
130+ Namespace : "foo" ,
131+ Labels : map [string ]string {
132+ "operators.coreos.com/foo" : "" ,
133+ "operators.coreos.com/bar" : "" ,
134+ "untouched" : "fine" ,
135+ },
136+ },
137+ },
138+ ExistingCopy : & v1alpha1.ClusterServiceVersion {
139+ ObjectMeta : metav1.ObjectMeta {
140+ Name : "name" ,
141+ Namespace : "bar" ,
142+ Labels : map [string ]string {
143+ "operators.coreos.com/foo" : "" ,
144+ "operators.coreos.com/bar" : "" ,
145+ "untouched" : "fine" ,
146+ },
147+ },
148+ Status : v1alpha1.ClusterServiceVersionStatus {
149+ Message : "The operator is running in foo but is managing this namespace" ,
150+ Reason : v1alpha1 .CSVReasonCopied },
151+ },
152+ ExpectedResult : & v1alpha1.ClusterServiceVersion {
153+ ObjectMeta : metav1.ObjectMeta {
154+ Name : "name" ,
155+ Namespace : "bar" ,
156+ Labels : map [string ]string {
157+ "untouched" : "fine" ,
158+ "olm.copiedFrom" : "foo" ,
159+ },
160+ },
161+ Status : v1alpha1.ClusterServiceVersionStatus {
162+ Message : "The operator is running in foo but is managing this namespace" ,
163+ Reason : v1alpha1 .CSVReasonCopied ,
164+ },
165+ },
166+ ExpectedActions : []ktesting.Action {
167+ ktesting .NewUpdateAction (gvr , "bar" , & v1alpha1.ClusterServiceVersion {
168+ ObjectMeta : metav1.ObjectMeta {
169+ Name : "name" ,
170+ Namespace : "bar" ,
171+ Labels : map [string ]string {
172+ "untouched" : "fine" ,
173+ "olm.copiedFrom" : "foo" ,
174+ },
175+ },
176+ Status : v1alpha1.ClusterServiceVersionStatus {
177+ Message : "The operator is running in foo but is managing this namespace" ,
178+ Reason : v1alpha1 .CSVReasonCopied ,
179+ },
180+ }),
181+ },
182+ },
124183 } {
125184 t .Run (tc .Name , func (t * testing.T ) {
126185 lister := & operatorlisterfakes.FakeOperatorLister {}
0 commit comments