@@ -4724,6 +4724,116 @@ func TestSyncOperatorGroups(t *testing.T) {
4724
4724
},
4725
4725
}},
4726
4726
},
4727
+ {
4728
+ // ensure that ownership labels are fixed but user labels are preserved
4729
+ name : "MatchingNamespace/NoCSVs/ClusterRoleOwnershipLabels" ,
4730
+ expectedEqual : true ,
4731
+ initial : initial {
4732
+ operatorGroup : & operatorsv1.OperatorGroup {
4733
+ ObjectMeta : metav1.ObjectMeta {
4734
+ Name : "operator-group-1" ,
4735
+ Namespace : operatorNamespace },
4736
+ Spec : operatorsv1.OperatorGroupSpec {
4737
+ Selector : & metav1.LabelSelector {
4738
+ MatchLabels : map [string ]string {"app" : "app-a" },
4739
+ },
4740
+ },
4741
+ },
4742
+ k8sObjs : []runtime.Object {
4743
+ & corev1.Namespace {
4744
+ ObjectMeta : metav1.ObjectMeta {
4745
+ Name : operatorNamespace ,
4746
+ },
4747
+ },
4748
+ & corev1.Namespace {
4749
+ ObjectMeta : metav1.ObjectMeta {
4750
+ Name : targetNamespace ,
4751
+ Labels : map [string ]string {"app" : "app-a" },
4752
+ },
4753
+ },
4754
+ & rbacv1.ClusterRole {
4755
+ ObjectMeta : metav1.ObjectMeta {
4756
+ ResourceVersion : "" ,
4757
+ Name : "olm.og.operator-group-1.admin-8rdAjL0E35JMMAkOqYmoorzjpIIihfnj3DcgDU" ,
4758
+ Labels : map [string ]string {
4759
+ "olm.owner" : "operator-group-1" ,
4760
+ "olm.owner.namespace" : "operator-ns-bob" ,
4761
+ "olm.owner.kind" : "OperatorGroup" ,
4762
+ "not.an.olm.label" : "true" ,
4763
+ },
4764
+ },
4765
+ },
4766
+ & rbacv1.ClusterRole {
4767
+ ObjectMeta : metav1.ObjectMeta {
4768
+ ResourceVersion : "" ,
4769
+ Name : "olm.og.operator-group-1.view-1l6ymczPK5SceF4d0DCtAnWZuvmKn6s8oBUxHr" ,
4770
+ Labels : map [string ]string {
4771
+ "olm.owner" : "operator-group-5" ,
4772
+ "olm.owner.namespace" : "operator-ns" ,
4773
+ "olm.owner.kind" : "OperatorGroup" ,
4774
+ "not.an.olm.label" : "false" ,
4775
+ "another.olm.label" : "or maybe not" ,
4776
+ },
4777
+ },
4778
+ },
4779
+ & rbacv1.ClusterRole {
4780
+ ObjectMeta : metav1.ObjectMeta {
4781
+ ResourceVersion : "" ,
4782
+ Name : "olm.og.operator-group-1.edit-9lBEUxqAYE7CX7wZfFEPYutTfQTo43WarB08od" ,
4783
+ Labels : map [string ]string {
4784
+ "olm.owner" : "operator-group-1" ,
4785
+ "olm.owner.namespace" : "operator-ns" ,
4786
+ "olm.owner.kind" : "OperatorGroupKind" ,
4787
+ },
4788
+ },
4789
+ },
4790
+ },
4791
+ },
4792
+ expectedStatus : operatorsv1.OperatorGroupStatus {
4793
+ Namespaces : []string {targetNamespace },
4794
+ LastUpdated : & now ,
4795
+ },
4796
+ final : final {objects : map [string ][]runtime.Object {
4797
+ "" : {
4798
+ & rbacv1.ClusterRole {
4799
+ ObjectMeta : metav1.ObjectMeta {
4800
+ ResourceVersion : "" ,
4801
+ Name : "olm.og.operator-group-1.admin-8rdAjL0E35JMMAkOqYmoorzjpIIihfnj3DcgDU" ,
4802
+ Labels : map [string ]string {
4803
+ "olm.owner" : "operator-group-1" ,
4804
+ "olm.owner.namespace" : "operator-ns" ,
4805
+ "olm.owner.kind" : "OperatorGroup" ,
4806
+ "not.an.olm.label" : "true" ,
4807
+ },
4808
+ },
4809
+ },
4810
+ & rbacv1.ClusterRole {
4811
+ ObjectMeta : metav1.ObjectMeta {
4812
+ ResourceVersion : "" ,
4813
+ Name : "olm.og.operator-group-1.edit-9lBEUxqAYE7CX7wZfFEPYutTfQTo43WarB08od" ,
4814
+ Labels : map [string ]string {
4815
+ "olm.owner" : "operator-group-1" ,
4816
+ "olm.owner.namespace" : "operator-ns" ,
4817
+ "olm.owner.kind" : "OperatorGroup" ,
4818
+ },
4819
+ },
4820
+ },
4821
+ & rbacv1.ClusterRole {
4822
+ ObjectMeta : metav1.ObjectMeta {
4823
+ ResourceVersion : "" ,
4824
+ Name : "olm.og.operator-group-1.view-1l6ymczPK5SceF4d0DCtAnWZuvmKn6s8oBUxHr" ,
4825
+ Labels : map [string ]string {
4826
+ "olm.owner" : "operator-group-1" ,
4827
+ "olm.owner.namespace" : "operator-ns" ,
4828
+ "olm.owner.kind" : "OperatorGroup" ,
4829
+ "not.an.olm.label" : "false" ,
4830
+ "another.olm.label" : "or maybe not" ,
4831
+ },
4832
+ },
4833
+ },
4834
+ },
4835
+ }},
4836
+ },
4727
4837
{
4728
4838
// if a cluster role exists with the correct name, use that
4729
4839
name : "MatchingNamespace/NoCSVs/DoesNotUpdateClusterRoles" ,
0 commit comments