.changes/v0.19.1.md
User defaults: persist any dagger function argument to .env by @shykes in https://github.com/dagger/dagger/pull/11034
This feature allows user to save arguments to their dagger functions to a local file, instead of re-typing them at every call. This way, the sandboxing of functions is preserved without sacrificing end-user convenience.
To use this feature, simply add variables to a local .env file reachable from your working directory. The format of the variables should be as follows:
mymod has a constructor argument foo: use variable name MYMOD_FOOmymod has a type foo, with a function bar, with an argument baz: use MYMOD_FOO_BAR_BAZAs a convenience, if your .env is inside the module, you may omit the module name:
foo: use variable name FOOfoo, with a function bar, with an argument baz: use FOO_BAR_BAZIn all cases, variable names are case-insensitive.
Any value which can be passed as a CLI flag, can also be used as a variable. The value will be interpreted the usual way, based on the argument's type. This includes:
INSTANCES=42 or username=adminregions=["us", "eu", "jp"]MYAPP_SOURCE=~/dev/myapp/srcDOCS=https://github.com/dagger/dagger#v0.19.0:docsdockerSocket=unix:///var/run/docker.sockgithubToken=env://PROD_TOKEN or sshKey=file://~/.ssh/id_dsapassword=op://my/vault/password/credentialbase=index.docker.io/alpine:latestTEST_DB=tcp://localhost:5432Note: one common issue with env files, is that they often contain secret values, and can be accidentally leaked via source control. Dagger helps avoid this issue, by requiring secrets to be stored as references. Even if your env file is accidentally leaked, it will only contain references, not actual secret values.