Skip to content

Commit

Permalink
Move BuildEnvMap to cmd/state
Browse files Browse the repository at this point in the history
To avoid increasing the size of lib/.

See #2821 (comment)
  • Loading branch information
Ivan Mirić committed Jan 16, 2023
1 parent 2471784 commit 504f134
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/config_consolidation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func runTestCase(t *testing.T, testCase configConsolidationTestCase, subCmd stri

ts := tests.NewGlobalTestState(t)
ts.CmdArgs = append([]string{"k6", subCmd}, testCase.options.cli...)
ts.Env = lib.BuildEnvMap(testCase.options.env)
ts.Env = state.BuildEnvMap(testCase.options.env)
if testCase.options.fs != nil {
ts.GlobalState.FS = testCase.options.fs
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/runtime_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/pflag"
"gopkg.in/guregu/null.v3"

"go.k6.io/k6/cmd/state"
"go.k6.io/k6/lib"
)

Expand Down Expand Up @@ -113,7 +114,7 @@ func getRuntimeOptions(flags *pflag.FlagSet, environment map[string]string) (lib
return opts, err
}
for _, kv := range envVars {
k, v := lib.ParseEnvKeyValue(kv)
k, v := state.ParseEnvKeyValue(kv)
// Allow only alphanumeric ASCII variable names for now
if !userEnvVarName.MatchString(k) {
return opts, fmt.Errorf("invalid environment variable name '%s'", k)
Expand Down
2 changes: 1 addition & 1 deletion lib/env.go → cmd/state/env.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lib
package state

import "strings"

Expand Down
3 changes: 1 addition & 2 deletions cmd/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/afero"

"go.k6.io/k6/lib"
"go.k6.io/k6/ui/console"
)

Expand Down Expand Up @@ -77,7 +76,7 @@ func NewGlobalState(ctx context.Context) *GlobalState {
IsTTY: stderrTTY,
}

env := lib.BuildEnvMap(os.Environ())
env := BuildEnvMap(os.Environ())
_, noColorsSet := env["NO_COLOR"] // even empty values disable colors
logger := &logrus.Logger{
Out: stderr,
Expand Down

0 comments on commit 504f134

Please sign in to comment.