Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tanka-util] patchKubernetesObjects should not patch references #956

Open
rassie opened this issue Apr 4, 2023 · 0 comments
Open

[tanka-util] patchKubernetesObjects should not patch references #956

rassie opened this issue Apr 4, 2023 · 0 comments

Comments

@rassie
Copy link

rassie commented Apr 4, 2023

Consider the following code:

tanka.k8s.patchKubernetesObjects(
    data,
    {
      metadata+: {
        annotations+: {
          'route.openshift.io/termination': 'edge',
        },
      },
    },
    kind='Ingress'
  )

This is supposed to traverse data, find all objects of kind Ingress and patch them. However, currently patchKubernetesObjects also triggers on references, e.g. such as used by the patch-operator:

{
    apiVersion: 'redhatcop.redhat.io/v1alpha1',
    kind: 'Patch',
    metadata: {
      name: 'setup-cluster-ingress',
      namespace: 'openshift-config',
    },
    spec: {
      patches: {
        'setup-cluster-ingress': {
          targetObjectRef: {
            apiVersion: 'config.openshift.io/v1',
            kind: 'Ingress',
            name: 'cluster',
          },
          patchTemplate: "",
          patchType: 'application/merge-patch+json',
          sourceObjectRefs: [],
        },
      },
    },
  }

The targetObjectRef requires both apiVersion and kind to properly resolve the target object, but these two fields also trigger patchKubernetesObjects detection.

I'm not quite sure how to resolve this properly, since the recursive step is required. Maybe detecting a apiVersion and kind and not recursing into that object could work, but I'm not sure if that's correct or expected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant