Skip to content

Manipulate list items with patch #4950

@odbaeu

Description

@odbaeu

Eschewed features

  • This issue is not requesting templating, unstuctured edits, build-time side-effects from args or env vars, or any other eschewed feature.

What would you like to have added?

replacements allows to reference list items via this syntax: spec.template.spec.containers.*.env.[name=TARGET_ENV].value. We need to be able to reference list items with the same/similar syntax in patches, too.

Example:
manifest:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: simple-service
  namespace: argocd
spec:
  destination:
    namespace: default
    server: https://kubernetes.host
  source:
    helm:
      parameters:
      - name: test
        value: asdf
      - name: docker.registry
        value: some.docker.host

replace:

- op: replace
  path: "/spec/source/helm/parameters/[name=test].value"
  value: foo

Why is this needed?

Referencing list items via an index is not very convenient... Someone could change the order of the list which would break our replacement config. This could result in an outage and even a data breach.

Can you accomplish the motivating task without this feature, and if so, how?

I've been searching for an appropriate workaround for days but I could not find any. Except using index, which is not reliable enough.

What other solutions have you considered?

I considered using replacements but for my use case I can't use a configMap. ArgoCD does not accept a configMap as input for parameters. But I'm very sure that there are a lot more use cases than just this one. I searched a lot for a solution and I discovered many people who are looking for the same solution. (see #kustomize channel on slack).

Anything else we should know?

No response

Feature ownership

  • I am interested in contributing this feature myself! 🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.triage/out-of-scopeIndicates an issue or PR is not a fit for Kustomize's scope and/or principles

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions