File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 88 "github.com/spf13/cobra"
99 "go.jetpack.io/devbox/internal/devbox"
1010 "go.jetpack.io/devbox/internal/devbox/devopt"
11+ "go.jetpack.io/devbox/internal/ux"
1112 "go.jetpack.io/envsec/pkg/envsec"
1213)
1314
@@ -204,9 +205,18 @@ func secretsInitFunc(
204205 if err != nil {
205206 return errors .WithStack (err )
206207 }
207- if err := secrets .NewProject (ctx , flags .force ); err != nil {
208+
209+ if _ , err := secrets .ProjectConfig (); err == nil &&
210+ box .Config ().EnvFrom != "jetpack-cloud" {
211+ // Handle edge case where directory is already set up, but devbox.json is
212+ // not configured to use jetpack-cloud.
213+ ux .Finfo (
214+ cmd .ErrOrStderr (),
215+ "Secrets already initialized. Adding to devbox config.\n " ,
216+ )
217+ } else if err := secrets .NewProject (ctx , flags .force ); err != nil {
208218 return errors .WithStack (err )
209219 }
210- box .Config ().SetStringField ("EnvFrom" , "envsec " )
220+ box .Config ().SetStringField ("EnvFrom" , "jetpack-cloud " )
211221 return box .Config ().SaveTo (box .ProjectDir ())
212222}
Original file line number Diff line number Diff line change @@ -1104,6 +1104,7 @@ func (d *Devbox) configEnvs(
11041104 ctx context.Context ,
11051105 existingEnv map [string ]string ,
11061106) (map [string ]string , error ) {
1107+ defer debug .FunctionTimer ().End ()
11071108 env := map [string ]string {}
11081109 if d .cfg .IsEnvsecEnabled () {
11091110 secrets , err := d .Secrets (ctx )
@@ -1129,7 +1130,10 @@ func (d *Devbox) configEnvs(
11291130 }
11301131 } else if d .cfg .EnvFrom != "" {
11311132 return nil , usererr .New (
1132- "unknown from_env value: %s. Supported value is: envsec." , d .cfg .EnvFrom )
1133+ "unknown from_env value: %s. Supported value is: %q." ,
1134+ d .cfg .EnvFrom ,
1135+ "jetpack-cloud" ,
1136+ )
11331137 }
11341138 for k , v := range d .cfg .Env {
11351139 env [k ] = v
Original file line number Diff line number Diff line change 11package devconfig
22
33func (c * Config ) IsEnvsecEnabled () bool {
4- return c .EnvFrom == "envsec"
4+ // envsec for legacy.
5+ return c .EnvFrom == "envsec" || c .EnvFrom == "jetpack-cloud"
56}
You can’t perform that action at this time.
0 commit comments