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

Can't define the same VAR in multiple bases #696

Closed
sethpollack opened this issue Jan 13, 2019 · 2 comments
Closed

Can't define the same VAR in multiple bases #696

sethpollack opened this issue Jan 13, 2019 · 2 comments

Comments

@sethpollack
Copy link
Contributor

sethpollack commented Jan 13, 2019

cat <<'EOF' > kustomization.yaml
apiVersion: v1beta1
kind: Kustomization

bases:
- base1
- base2
EOF
cat <<'EOF' > base1/kustomization.yaml
apiVersion: v1beta1
kind: Kustomization

configMapGenerator:
- literals:
  - MY_ENV=foo
  name: example1

vars:
- fieldref:
    fieldPath: data.MY_ENV
  name: MY_ENV
  objref:
    apiVersion: v1
    kind: ConfigMap
    name: example1
EOF
cat <<'EOF' > base2/kustomization.yaml
apiVersion: v1beta1
kind: Kustomization

configMapGenerator:
- literals:
  - MY_ENV=foo
  name: example2

vars:
- fieldref:
    fieldPath: data.MY_ENV
  name: MY_ENV
  objref:
    apiVersion: v1
    kind: ConfigMap
    name: example2
EOF

This gets the following error:

Error: base2: var MY_ENV already encountered
@monopole
Copy link
Contributor

monopole commented Jan 23, 2019

A var in a base is supposed to be available in an overlay; its scope goes all the way "up".

So vars with the same name at the same level must be disallowed.

The use case described here doesn't attempt to use a var in the overlay, but they are available for use, and they collide (creating an ambiguity), so the error is legit. I suppose we could add code to detect and allow this case, but is it worth it when the fix is simply to change the var name?

@sethpollack
Copy link
Contributor Author

Ok thanks. I can work around this. Just seemed like it was different from the way things usually work in kustomize.

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

2 participants