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

[feature request] Support defaults in template fields #2255

Closed
dkirrane opened this issue Jun 11, 2019 · 5 comments
Closed

[feature request] Support defaults in template fields #2255

dkirrane opened this issue Jun 11, 2019 · 5 comments
Labels
area/config kind/feature-request priority/awaiting-more-evidence Lowest Priority. May be useful, but there is not yet enough supporting evidence.

Comments

@dkirrane
Copy link

dkirrane commented Jun 11, 2019

I'm looking for something like the following.
If VERSION env variable isn't set use USERNAME env variable otherwise use latest as the default for the image tag.

This is for a developer workflow where Jenkins would set the VERSION but the developer on their machine would user their own USERNAME as the image tag. And if the developer doesn't have USERNAME variable (like on a Mac) it will fall back to latest

apiVersion: skaffold/v1beta11
kind: Config
build:
  tagPolicy:
    envTemplate:
      template: "{{.IMAGE_NAME}}:{{ .VERSION | .USERNAME | default('latest') }}"
@nkubala
Copy link
Contributor

nkubala commented Jun 19, 2019

would it make more sense to just use different profiles here? evaluating env vars is pretty different than evaluating logical statements when generating the envTemplate tags.

build:
  tagPolicy:
    envTemplate:
      template: "{{.IMAGE_NAME}}:{{.USERNAME}}"
profiles:
  - name: jenkins
    build:
    tagPolicy:
      envTemplate:
        template: "{{.IMAGE_NAME}}:{{.VERSION}}"

@balopat balopat added area/config priority/awaiting-more-evidence Lowest Priority. May be useful, but there is not yet enough supporting evidence. labels Aug 17, 2019
@no1melman
Copy link

I would prefer something like this

build:
  artifacts:
  - image: cool
    docker:
      buildArgs:
        RUNTESTS: "{{ default .RUNTESTS '0' }}"

Where I can export RUNTESTS="1" to run the tests, or it gets defaulted to "0"

@gentunian
Copy link

why not to keep it "standard" or related to what helm does so it follows a common idea: https://helm.sh/docs/chart_template_guide/variables/

foo: {{ .MY_VAR | default "" }}

@okgolove
Copy link

It seems this PR resolves the issue

@nkubala
Copy link
Contributor

nkubala commented Aug 2, 2021

closed via #6136

@nkubala nkubala closed this as completed Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/feature-request priority/awaiting-more-evidence Lowest Priority. May be useful, but there is not yet enough supporting evidence.
Projects
None yet
Development

No branches or pull requests

7 participants