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

optional env deck variables #1024

Open
zekth opened this issue Sep 9, 2023 · 0 comments
Open

optional env deck variables #1024

zekth opened this issue Sep 9, 2023 · 0 comments

Comments

@zekth
Copy link
Member

zekth commented Sep 9, 2023

Currently all env variables need to be set when using deck, however it creates a problem with some cases and deck usages. Take this as an example:

plugins:
- name: acme
  config:
    account_email: ${{ env "DECK_ACME_ACCOUNT_EMAIL" }}
    api_uri: ${{ env "DECK_ACME_API_URI" }}
    eab_kid: ${{ env "DECK_ACME_EAB_KEY_ID" }}
    eab_hmac_key: ${{ env "DECK_ACME_EAB_SECRET" }}
    ${{- if env "DECK_ACME_ACCOUNT_KEY" }}
    account_key: ${{ env "DECK_ACME_ACCOUNT_KEY" }}
    ${{- end }}
    allow_any_domain: true
    tos_accepted: true
    storage: redis
    storage_config:
      redis:
        host: ${{ env "DECK_REDIS_HOST" }}
        port: 6379
        auth: ${{ env "DECK_REDIS_KEY" }}
        ssl: true
        ssl_verify: false

So we have potential cases where DECK_ACME_ACCOUNT_KEY is set, in the helm context when deploying the deck config. However by this if condition it makes the deck file merge unusable because it's not a valid yaml file.

What we can do is introducing envOptional to get rid of this problem. So envOptional would just output an empty string ''; in addition to this we can add also a nullFallback function to return null in case of empty string. So in this case would have a template like this:

plugins:
- name: acme
  config:
...
    account_key: ${{ envOptional "DECK_ACME_ACCOUNT_KEY" }}

will output

```yaml
plugins:
- name: acme
  config:
...
    account_key: ''

with nullFallback we would have this

plugins:
- name: acme
  config:
...
    account_key: ${{ envOptional "DECK_ACME_ACCOUNT_KEY" | nullFallback }}

will output

```yaml
plugins:
- name: acme
  config:
...
    account_key: null

And this would solve many of templating issues.

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

1 participant