#using dagger.Host().EnvVariable("FOO")

1 messages · Page 1 of 1 (latest)

faint kestrel
#

I'm trying out all the dagger functions listed in the Go api ref and wondering when I would rather use dagger.Host().EnvVariable("FOO") instead of just loading envs normally with os.Getenv("FOO").

Could someone clarify this?

wary laurel
#

it'll probably be removed soon. it was added so we could support loading env vars as secrets, but there's a new secrets api now that lets you just do dagger.SetSecret("foo", os.Getenv("BAR")) instead

faint kestrel
#

right, that's what I assumed, thanks 🙌

faint kestrel
#

ohh.. this is so sweet!

sec := client.SetSecret("someToken", os.Getenv("SOME_TOKEN"))
baseImage := client.Container().From(baseImage)
img := baseImage.
    WithSecretVariable("SOME_TOKEN", sec)
...
debug(img.WithExec([]string{"env"})) -> SOME_TOKEN=***
delicate nest
#

Is this in the latest SDK releases?

#

I'm stuck on a slightly older SDK until Alpine3.17 ships with Python 3.11 or my org updates our base image

faint kestrel
#

I think it was in v0.4.1

delicate nest
#

That might explain why I've not seen/tried it yet

stable pond
#

@rigid turtle and @modern tide are working on a new secrets guide now