@@ -3,11 +3,11 @@ package cache
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
- "regexp"
7
6
v1 "k8s.io/api/apps/v1"
8
7
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9
8
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
10
9
"k8s.io/apimachinery/pkg/types"
10
+ "regexp"
11
11
12
12
"github.com/argoproj/gitops-engine/pkg/utils/kube"
13
13
)
@@ -25,15 +25,15 @@ func (c *clusterCache) resolveResourceReferences(un *unstructured.Unstructured)
25
25
switch {
26
26
27
27
// Special case for endpoint. Remove after https://github.com/kubernetes/kubernetes/issues/28483 is fixed
28
- case gvk .Group == "" && gvk .Kind == kube .EndpointsKind && len (un . GetOwnerReferences () ) == 0 :
28
+ case gvk .Group == "" && gvk .Kind == kube .EndpointsKind && len (ownerRefs ) == 0 :
29
29
ownerRefs = append (ownerRefs , metav1.OwnerReference {
30
30
Name : un .GetName (),
31
31
Kind : kube .ServiceKind ,
32
32
APIVersion : "v1" ,
33
33
})
34
34
35
35
// Special case for Operator Lifecycle Manager ClusterServiceVersion:
36
- case un . GroupVersionKind (). Group == "operators.coreos.com" && un . GetKind () == "ClusterServiceVersion" :
36
+ case gvk . Group == "operators.coreos.com" && gvk . Kind == "ClusterServiceVersion" :
37
37
if un .GetAnnotations ()["olm.operatorGroup" ] != "" {
38
38
ownerRefs = append (ownerRefs , metav1.OwnerReference {
39
39
Name : un .GetAnnotations ()["olm.operatorGroup" ],
@@ -43,12 +43,12 @@ func (c *clusterCache) resolveResourceReferences(un *unstructured.Unstructured)
43
43
}
44
44
45
45
// Edge case: consider auto-created service account tokens as a child of service account objects
46
- case un . GetKind () == kube .SecretKind && un . GroupVersionKind () .Group == "" :
46
+ case gvk . Kind == kube .SecretKind && gvk .Group == "" :
47
47
if yes , ref := isServiceAccountTokenSecret (un ); yes {
48
48
ownerRefs = append (ownerRefs , ref )
49
49
}
50
50
51
- case (un . GroupVersionKind (). Group == "apps" || un . GroupVersionKind (). Group == "extensions" ) && un . GetKind () == kube .StatefulSetKind :
51
+ case (gvk . Group == "apps" || gvk . Group == "extensions" ) && gvk . Kind == kube .StatefulSetKind :
52
52
if refs , err := isStatefulSetChild (un ); err != nil {
53
53
c .log .Error (err , fmt .Sprintf ("Failed to extract StatefulSet %s/%s PVC references" , un .GetNamespace (), un .GetName ()))
54
54
} else {
@@ -74,7 +74,7 @@ func isStatefulSetChild(un *unstructured.Unstructured) (func(kube.ResourceKey) b
74
74
return func (key kube.ResourceKey ) bool {
75
75
if key .Kind == kube .PersistentVolumeClaimKind && key .GroupKind ().Group == "" {
76
76
for _ , templ := range templates {
77
- if match , _ := regexp .MatchString (fmt .Sprintf (`%s-%s-\d+$` , templ .Name , un .GetName ()), key .Name ); match {
77
+ if match , _ := regexp .MatchString (fmt .Sprintf (`%s-%s-\d+$` , templ .Name , un .GetName ()), key .Name ); match {
78
78
return true
79
79
}
80
80
}
0 commit comments