optional env deck variables
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 505
- Forks
- 137
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 20
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's proposed envOptional and nullFallback behavior, then locate decK's existing environment-variable template handling and its tests. Confirm how empty strings and null values are rendered and parsed, and consider both standalone optional values and pipeline usage; done means optional variables no longer require conditional YAML and the documented examples produce valid configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100