Skip to content

Commit 6eb81c5

Browse files
authored
Merge pull request #19 from pib/env-for-workspace-new
Fix: provide environment variables when running `tofu workspace new`
2 parents a8a147b + 6829e48 commit 6eb81c5

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

internal/opentofu/opentofu.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ func (h Harness) Workspace(ctx context.Context, name string) error {
254254
// is somewhat optimistic, but it shouldn't hurt to try.
255255
cmd = exec.Command(h.Path, "workspace", "new", "-no-color", name) //nolint:gosec
256256
cmd.Dir = h.Dir
257+
if len(h.Envs) > 0 {
258+
cmd.Env = append(os.Environ(), h.Envs...)
259+
}
257260

258261
if h.UsePluginCache {
259262
rwmutex.RLock()

0 commit comments

Comments
 (0)