#.env file has to contain only the value (no key)?

1 messages · Page 1 of 1 (latest)

fair rune
#

I have an .env file containing some secrets. Those secrets are in the following form:

.env:

secret-KEY-1=secret-value-1
secret-KEY-2=secret-value-2

I found out that I was only able to successfully pass a secret to a function when the .env file resembles the following:

.env.dagger:

secret-value-1

That is, no key nor any other secret. So, basically I had to create another file just to be able to do that.

Is there a way to still pass a secret when my .env file is in its original form (first codeblock)?

The API I am using is .withSecretVariable("Token", token) and I am calling it like that:
dagger call build --source=. --token=file:./.env.dagger

keen idol
#

there's 2 things in here actually...

first, no, i don't think there's a dagger call for parsing env files, but if we're talking go SDK code, i'd reccommend https://github.com/hashicorp/go-envparse.

second, there's not a plural withSecretVariables(map[string][string]) either... in other languages it'd be kinda useless, bc you'd prolly just wanna map withSecretVariable over the entries. you could use lo if you want

GitHub

Minimal environment variable parser for Go. Contribute to hashicorp/go-envparse development by creating an account on GitHub.

GitHub

💥 A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...) - samber/lo

keen idol
#

actually now noticing the lowercase here, what SDK are you using?

fair rune
#

Sorry. I was not notified about this message.

I am using the Typescript SDK

#

I just don’t want to have to create one env file specifically for dagger when I already have one. I’d like to be able to use the same env file I already have in my project.

keen idol
fair rune
#

Yeh, I understood that.

I just thought dagger would have something built in.

keen idol
#

definitely nothing built-in atm, but this could be a sensible thing to put in a freestanding public dagger module. aside from modulizing it, if you go and do it in code and there turns out to be something awkward about it, feel free to submit an issue!