@@ -10,6 +10,8 @@ import (
10
10
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
11
11
"k8s.io/apimachinery/pkg/types"
12
12
13
+ synccommon "github.com/argoproj/gitops-engine/pkg/sync/common"
14
+ syncresource "github.com/argoproj/gitops-engine/pkg/sync/resource"
13
15
"github.com/argoproj/gitops-engine/pkg/utils/kube"
14
16
)
15
17
@@ -20,15 +22,17 @@ func mightHaveInferredOwner(r *Resource) bool {
20
22
21
23
func (c * clusterCache ) resolveResourceReferences (un * unstructured.Unstructured ) ([]metav1.OwnerReference , func (kube.ResourceKey ) bool ) {
22
24
var isInferredParentOf func (_ kube.ResourceKey ) bool
23
- allOwnerRefs := un .GetOwnerReferences ()
25
+ ownerRefs := un .GetOwnerReferences ()
24
26
gvk := un .GroupVersionKind ()
25
27
26
- // TODO: Put this behind a gate
27
- ownerRefs := []metav1.OwnerReference {}
28
- for _ , ownerRef := range allOwnerRefs {
29
- if ownerRef .Controller != nil && * ownerRef .Controller {
30
- ownerRefs = append (ownerRefs , ownerRef )
28
+ if syncresource .HasAnnotationOption (un , synccommon .AnnotationSyncOptions , synccommon .SyncOptionControllerReferencesOnly ) {
29
+ controllerOwnerRefs := []metav1.OwnerReference {}
30
+ for _ , ownerRef := range un .GetOwnerReferences () {
31
+ if ownerRef .Controller != nil && * ownerRef .Controller {
32
+ controllerOwnerRefs = append (controllerOwnerRefs , ownerRef )
33
+ }
31
34
}
35
+ return controllerOwnerRefs , isInferredParentOf
32
36
}
33
37
34
38
switch {
0 commit comments