Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit abacb05

Browse files
committed
Undo making osEnv a function
1 parent 708dc47 commit abacb05

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

internals/secrethub/env_source.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
type environment struct {
2626
io ui.IO
27-
osEnv func() []string
27+
osEnv []string
2828
readFile func(filename string) ([]byte, error)
2929
osStat func(filename string) (os.FileInfo, error)
3030
envar map[string]string
@@ -38,7 +38,7 @@ type environment struct {
3838
func newEnvironment(io ui.IO) *environment {
3939
return &environment{
4040
io: io,
41-
osEnv: os.Environ,
41+
osEnv: os.Environ(),
4242
readFile: ioutil.ReadFile,
4343
osStat: os.Stat,
4444
templateVars: make(map[string]string),
@@ -57,7 +57,7 @@ func (env *environment) register(clause *cli.CommandClause) {
5757
}
5858

5959
func (env *environment) env() (map[string]value, error) {
60-
osEnvMap, _ := parseKeyValueStringsToMap(env.osEnv())
60+
osEnvMap, _ := parseKeyValueStringsToMap(env.osEnv)
6161
var sources []EnvSource
6262

6363
sources = append(sources, &osEnv{

internals/secrethub/run_test.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,7 @@ func TestRunCommand_Run(t *testing.T) {
589589
command: []string{"echo", "test"},
590590
io: ui.NewFakeIO(),
591591
environment: &environment{
592-
osEnv: func() []string {
593-
return []string{"TEST=secrethub://nonexistent/secret/path"}
594-
},
592+
osEnv: []string{"TEST=secrethub://nonexistent/secret/path"},
595593
osStat: osStatNotExist,
596594
},
597595
newClient: func() (secrethub.ClientInterface, error) {
@@ -614,9 +612,7 @@ func TestRunCommand_Run(t *testing.T) {
614612
command: []string{"echo", "test"},
615613
io: ui.NewFakeIO(),
616614
environment: &environment{
617-
osEnv: func() []string {
618-
return []string{"TEST=secrethub://nonexistent/secret/path"}
619-
},
615+
osEnv: []string{"TEST=secrethub://nonexistent/secret/path"},
620616
osStat: osStatNotExist,
621617
},
622618
newClient: func() (secrethub.ClientInterface, error) {
@@ -776,9 +772,7 @@ func TestRunCommand_environment(t *testing.T) {
776772
readFile: readFileFunc("secrethub.env", "TEST=aaa"),
777773
dontPromptMissingTemplateVar: true,
778774
templateVersion: "2",
779-
osEnv: func() []string {
780-
return []string{"TEST=secrethub://test/test/test"}
781-
},
775+
osEnv: []string{"TEST=secrethub://test/test/test"},
782776
},
783777
newClient: func() (secrethub.ClientInterface, error) {
784778
return fakeclient.Client{
@@ -891,9 +885,7 @@ func TestRunCommand_environment(t *testing.T) {
891885
readFile: readFileFunc("secrethub.env", "TEST = {{ test/$variable/test }}"),
892886
dontPromptMissingTemplateVar: true,
893887
templateVersion: "2",
894-
osEnv: func() []string {
895-
return []string{"SECRETHUB_VAR_VARIABLE=test"}
896-
},
888+
osEnv: []string{"SECRETHUB_VAR_VARIABLE=test"},
897889
},
898890
newClient: func() (secrethub.ClientInterface, error) {
899891
return fakeclient.Client{

0 commit comments

Comments
 (0)