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

In replacements, the type of source value is not retained when the target fieldPath is not existent an configured with option.create: true #5482

Open
ElSamhaa opened this issue Dec 8, 2023 · 3 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.

Comments

@ElSamhaa
Copy link

ElSamhaa commented Dec 8, 2023

What happened?

I'm trying to override an environment variable that might or might not exist in the base. I'm using a local config as a source with the numeric value as a string.

When the base happens to have that overridden environment variable defined, it retains the type right. However, whenever the base is missing the environment variable, the env is created with the numeric value as an integer; not as a string like in the source field.

What did you expect to happen?

The type of the source value should be retained under all conditions.

How can we reproduce it (as minimally and precisely as possible)?

# resources.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: local-config
  annotations:
    config.kubernetes.io/local-config: "true"
data:
  ENV_TEST: "10"
---
apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
  - image: alpine
    name: test
# kustomization.yaml
resources:
- resources.yaml

replacements:
- source:
    kind: ConfigMap
    name: local-config
    fieldPath: data.ENV_TEST
  targets:
  - select:
      kind: Pod
    options:
      create: true
    fieldPaths:
    - spec.containers.[name=test].env.[name=TEST].value

Expected output

apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
  - env:
    - name: TEST
      value: "10"
    image: alpine
    name: test

Actual output

apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
  - env:
    - name: TEST
      value: 10 # the value type is integer; does not match the type in the source (string)
    image: alpine
    name: test

Kustomize version

v5.3.0

Operating system

MacOS

@ElSamhaa ElSamhaa added the kind/bug Categorizes issue or PR as related to a bug. label Dec 8, 2023
@k8s-ci-robot
Copy link
Contributor

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.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 8, 2023
@ElSamhaa ElSamhaa changed the title In replacements, the type of source value not retained when the target is not existent and is configured with option.create: true In replacements, the type of source value is not retained when the target fieldPath is not existent an configured with option.create: true Dec 8, 2023
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 7, 2024
@quentinus95
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 17, 2024
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.
Projects
None yet
Development

No branches or pull requests

4 participants