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

kustomize build with replacements alter the replacement source #4003

Closed
vmwiz opened this issue Jun 17, 2021 · 2 comments
Closed

kustomize build with replacements alter the replacement source #4003

vmwiz opened this issue Jun 17, 2021 · 2 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/duplicate Indicates an issue is a duplicate of other open issue.

Comments

@vmwiz
Copy link

vmwiz commented Jun 17, 2021

When using replacements to fetch a value from a label and use it somewhere else to build a path, the label of the source is replaced by the target value

Files that can reproduce the issue

kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

commonLabels:
  environment: development
  platform: acme_corp

resources:
- namespace.yaml
- application.yaml

replacements:
- source:
    kind: Namespace
    name: test
    fieldPath: metadata.labels.environment
  targets:
  - select:
      kind: Application
    fieldPaths:
    - spec.source.path
    options:
      delimiter: "/"
      index: 2
- source:
    kind: Namespace
    name: test
    fieldPath: metadata.labels.platform
  targets:
  - select:
      kind: Application
    fieldPaths:
    - spec.source.path
    options:
      delimiter: "/"
      index: 3
namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: test
application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
    name: eks-auth
spec:
  project: infra-components
  source:
    repoURL: https://git.repo.local/eks.git
    targetRevision: HEAD
    path: eks-auth/overlay
  destination:
    namespace: kube-system

Expected output

---
apiVersion: v1
kind: Namespace
metadata:
  labels:
    environment: development
    platform: acme_corp
  name: test
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  labels:
    environment: development
    platform: acme_corp
  name: eks-auth
  namespace: test
spec:
  destination:
    namespace: kube-system
  project: infra-components
  source:
    path: eks-auth/overlay/development/acme_corp
    repoURL: https://git.repo.local/eks.git
    targetRevision: HEAD

Actual output

---
apiVersion: v1
kind: Namespace
metadata:
  labels:
    environment: eks-auth/overlay/development
    platform: eks-auth/overlay/development/acme_corp
  name: test
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  labels:
    environment: development
    platform: acme_corp
  name: eks-auth
  namespace: test
spec:
  destination:
    namespace: kube-system
  project: kube-infra
  source:
    path: eks-auth/overlay/development/acme_corp
    repoURL: https://git.repo.local/eks.git
    targetRevision: HEAD

Kustomize version

❯ kustomize version
{Version:kustomize/v4.1.3 GitCommit:0f614e92f72f1b938a9171b964d90b197ca8fb68 BuildDate:2021-05-20T20:52:40Z GoOs:linux GoArch:amd64}

Platform

Linux

Additional context

@vmwiz vmwiz added the kind/bug Categorizes issue or PR as related to a bug. label Jun 17, 2021
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jun 17, 2021
@k8s-ci-robot
Copy link
Contributor

@vmwiz: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@natasha41575 natasha41575 added the triage/duplicate Indicates an issue is a duplicate of other open issue. label Jun 17, 2021
@natasha41575
Copy link
Contributor

natasha41575 commented Jun 17, 2021

Thank you for using and testing this feature!

This is a duplicate of #3927 and has been fixed in #3931 (I have confirmed that it works). If you need the fix now you can build from head, otherwise it will be available in the next release which I am hoping will be in the next couple of weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/duplicate Indicates an issue is a duplicate of other open issue.
Projects
None yet
Development

No branches or pull requests

3 participants