#User defaults question

1 messages ยท Page 1 of 1 (latest)

frosty geyser
#

Hi everyone, is there a plan to make user defaults work for functions and not just constructors ? I love the idea having defaults but sometimes it doesn't make sense to have all possible variables (that could be defaulted) at the constructor level.

chrome yoke
frosty geyser
#

love it ! Thanks @chrome yoke . Just one more question, is there a way to have it load from env variables directly or does it have to go through .env file

#

i basically want to avoid doing env > .env in my pipeline

chrome yoke
# frosty geyser love it ! Thanks <@488409085998530571> . Just one more question, is there a wa...

At the moment, .env file only. But:

  1. @crystal cradle just contributed a PR to allow that .env file to itself reference system variables. So that will be available in the next release (planned for later this week)
  2. It seems reasonable to also add support for loading user defaults directly from the system environment. We would just need to figure out the practicality of it, especially from a caching and security POV (basically how do we avoid doing the equivalent of env > .env in the dagger engine code ๐Ÿ˜› )
#

Another medium we're considering for setting user defaults, is a config file

frosty geyser
#

maybe the default pragma could be useful default="env:FOO"

#

this avoid loading all env but only the ones the module is actively looking for

chrome yoke
#

if you think of user defaults as configuration, it makes more sense.

crystal cradle
chrome yoke
frosty geyser
frosty geyser
#

@chrome yoke is there a difference in behavior while using default on an "external" module using dagger -m call ... ? I can't get that to load the variables

#

it doesnt seem to be picking up the .env file

chrome yoke
#

You can still set defaults for a remotely loaded module, by writing them to a .env outside the module directory, and prefixing the var names with the module name

#

The .env just needs to be available with a find-up search (standard .env search rules)

#

For example:

echo 'daggerDev_engineDev_test_run=TestUserDefaults' >> ~/.env
dagger -m github.com/dagger/dagger call engine-dev test

Note: daggerDev is the name of the module in github.com/dagger/dagger

frosty geyser
#

thanks for sending this ๐Ÿ™‚ it's really helpful

#

will give that a shot !

chrome yoke
#

As a nice side effect, this also means you can manage user defaults for multiple modules in a single .env file

frosty geyser
#

got it to work ! thanks @chrome yoke