Skip to content

Commit 399b7f3

Browse files
authored
[env] Fix env_from docs and improve error messaging (#2386)
## Summary See #2385 for context. ## How was it tested? Not
1 parent b3f6847 commit 399b7f3

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

docs/app/docs/configuration.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ Currently, you can only set values using string literals, `$PWD`, and `$PATH`. A
182182

183183
### Env From
184184

185-
Env from takes a string or list of strings for loading environment variables into your shells and scripts. Currently it supports loading from two sources: .env files, and Jetify Secrsts.
185+
Env from takes a string for loading environment variables into your shells and scripts. Currently it supports loading from two sources: .env files, and Jetify Secrets.
186186

187187
#### .env Files
188188

189-
You can load environment variables from a `.env` file by adding the path to the file in the `env_from` field. This is useful for loading secrets or other sensitive information that you don't want to store in your `devbox.json`.
189+
You can load environment variables from a `.env` file by adding the path to the file in the `env_from` field (the file must end with `.env`). This is useful for loading secrets or other sensitive information that you don't want to store in your `devbox.json`.
190190

191191
```json
192192
{
@@ -198,15 +198,15 @@ This will load the environment variables from the `.env` file into your shell wh
198198

199199
#### Jetify Secrets
200200

201-
You can securely load secrets from Jetify Secrets by running `devbox secrets init` and creating a project in Jetify Cloud. This will add the `jetpack-cloud` field to `env_from` in your project.
201+
You can securely load secrets from Jetify Secrets by running `devbox secrets init` and creating a project in Jetify Cloud. This will add the `jetify-cloud` field to `env_from` in your project.
202202

203203
```json
204204
{
205-
"env_from": "jetpack-cloud"
205+
"env_from": "jetify-cloud"
206206
}
207207
```
208208

209-
Note that setting secrets securetly with Jetify Secrets requires a Jetify Cloud account. For more information, see the [Jetify Secrets](/docs/cloud/secrets/) guide.
209+
Note that setting secrets securely with Jetify Secrets requires a Jetify Cloud account. For more information, see the [Jetify Secrets](/docs/cloud/secrets/) guide.
210210

211211
### Shell
212212

docs/app/docs/guides/secrets.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ For environment variables that you want to keep out of your `devbox.json` file,
2828
{
2929
"packages": {},
3030
"shell": {},
31-
"env_from": [
32-
"path/to/.env"
33-
]
31+
"env_from": "path/to/.env"
3432
}
3533
```
3634

internal/devbox/devbox.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"go.jetpack.io/devbox/internal/devbox/envpath"
3333
"go.jetpack.io/devbox/internal/devbox/generate"
3434
"go.jetpack.io/devbox/internal/devconfig"
35+
"go.jetpack.io/devbox/internal/devconfig/configfile"
3536
"go.jetpack.io/devbox/internal/devpkg"
3637
"go.jetpack.io/devbox/internal/devpkg/pkgtype"
3738
"go.jetpack.io/devbox/internal/envir"
@@ -1009,9 +1010,9 @@ func (d *Devbox) configEnvs(
10091010
}
10101011
} else if d.cfg.Root.EnvFrom != "" {
10111012
return nil, usererr.New(
1012-
"unknown from_env value: %s. Supported value is: %q.",
1013+
"unknown env_from value: %s. Supported values are: \"%q\" or a path to a file ending in \".env\"",
10131014
d.cfg.Root.EnvFrom,
1014-
"jetpack-cloud",
1015+
configfile.JetifyCloudEnvFromValue,
10151016
)
10161017
}
10171018
for k, v := range d.cfg.Env() {

internal/devconfig/configfile/env.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import (
88
"github.com/hashicorp/go-envparse"
99
)
1010

11+
var JetifyCloudEnvFromValue = "jetify-cloud"
12+
1113
func (c *ConfigFile) IsEnvsecEnabled() bool {
1214
// envsec for legacy. jetpack-cloud for legacy
13-
return c.EnvFrom == "envsec" || c.EnvFrom == "jetpack-cloud" || c.EnvFrom == "jetify-cloud"
15+
return c.EnvFrom == "envsec" || c.EnvFrom == "jetpack-cloud" || c.EnvFrom == JetifyCloudEnvFromValue
1416
}
1517

1618
func (c *ConfigFile) IsdotEnvEnabled() bool {

0 commit comments

Comments
 (0)