From d182d5dfc1eaec63aea632147d1c26c9472d35be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20L=C3=B3pez=20de=20la=20Franca=20Beltran?= Date: Thu, 4 Apr 2024 09:39:33 +0200 Subject: [PATCH] Update 'envconfig' to fix environment variables reads --- cmd/config_consolidation_test.go | 6 ++++++ go.mod | 2 +- go.sum | 4 ++-- .../mstoykov/envconfig/envconfig.go | 20 +++++++++---------- vendor/modules.txt | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/cmd/config_consolidation_test.go b/cmd/config_consolidation_test.go index a4211cfeef1..9324bb77e2a 100644 --- a/cmd/config_consolidation_test.go +++ b/cmd/config_consolidation_test.go @@ -335,6 +335,12 @@ func getConfigConsolidationTestCases() []configConsolidationTestCase { {opts{cli: []string{"--system-tags", `""`}}, exp{}, func(t *testing.T, c Config) { assert.Equal(t, metrics.SystemTagSet(0), *c.Options.SystemTags) }}, + {opts{env: []string{`K6_SYSTEM_TAGS=""`}}, exp{}, func(t *testing.T, c Config) { + assert.Equal(t, metrics.SystemTagSet(0), *c.Options.SystemTags) + }}, + {opts{env: []string{`K6_SYSTEM_TAGS=proto,method`}}, exp{}, func(t *testing.T, c Config) { + assert.Equal(t, metrics.SystemTagSet(metrics.TagProto|metrics.TagMethod), *c.Options.SystemTags) + }}, { opts{ runner: &lib.Options{ diff --git a/go.mod b/go.mod index 1414369b8d7..967f4693fcb 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/mattn/go-isatty v0.0.20 github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd - github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1 + github.com/mstoykov/envconfig v1.5.0 github.com/mstoykov/k6-taskqueue-lib v0.1.0 github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e diff --git a/go.sum b/go.sum index 67c33403231..817d74f9cf2 100644 --- a/go.sum +++ b/go.sum @@ -159,8 +159,8 @@ github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa h1:lx8ZnNPw github.com/mccutchen/go-httpbin v1.1.2-0.20190116014521-c5cb2f4802fa/go.mod h1:fhpOYavp5g2K74XDl/ao2y4KvhqVtKlkg1e+0UaQv7I= github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd h1:AC3N94irbx2kWGA8f/2Ks7EQl2LxKIRQYuT9IJDwgiI= github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd/go.mod h1:9vRHVuLCjoFfE3GT06X0spdOAO+Zzo4AMjdIwUHBvAk= -github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1 h1:94EkGmhXrVUEal+uLwFUf4fMXPhZpM5tYxuIsxrCCbI= -github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1/go.mod h1:vk/d9jpexY2Z9Bb0uB4Ndesss1Sr0Z9ZiGUrg5o9VGk= +github.com/mstoykov/envconfig v1.5.0 h1:E2FgWf73BQt0ddgn7aoITkQHmgwAcHup1s//MsS5/f8= +github.com/mstoykov/envconfig v1.5.0/go.mod h1:vk/d9jpexY2Z9Bb0uB4Ndesss1Sr0Z9ZiGUrg5o9VGk= github.com/mstoykov/k6-taskqueue-lib v0.1.0 h1:M3eww1HSOLEN6rIkbNOJHhOVhlqnqkhYj7GTieiMBz4= github.com/mstoykov/k6-taskqueue-lib v0.1.0/go.mod h1:PXdINulapvmzF545Auw++SCD69942FeNvUztaa9dVe4= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= diff --git a/vendor/github.com/mstoykov/envconfig/envconfig.go b/vendor/github.com/mstoykov/envconfig/envconfig.go index b6bfcc788a8..ff15deca2c9 100644 --- a/vendor/github.com/mstoykov/envconfig/envconfig.go +++ b/vendor/github.com/mstoykov/envconfig/envconfig.go @@ -253,14 +253,6 @@ func processField(value string, field reflect.Value) error { return setter.Set(value) } - if t := textUnmarshaler(field); t != nil { - return t.UnmarshalText([]byte(value)) - } - - if b := binaryUnmarshaler(field); b != nil { - return b.UnmarshalBinary([]byte(value)) - } - if typ.Kind() == reflect.Ptr { typ = typ.Elem() if field.IsNil() { @@ -269,6 +261,14 @@ func processField(value string, field reflect.Value) error { field = field.Elem() } + if t := textUnmarshaler(field); t != nil { + return t.UnmarshalText([]byte(value)) + } + + if b := binaryUnmarshaler(field); b != nil { + return b.UnmarshalBinary([]byte(value)) + } + switch typ.Kind() { case reflect.String: field.SetString(value) @@ -311,7 +311,7 @@ func processField(value string, field reflect.Value) error { sl := reflect.MakeSlice(typ, 0, 0) if typ.Elem().Kind() == reflect.Uint8 { sl = reflect.ValueOf([]byte(value)) - } else if len(strings.TrimSpace(value)) != 0 { + } else if strings.TrimSpace(value) != "" { vals := strings.Split(value, ",") sl = reflect.MakeSlice(typ, len(vals), len(vals)) for i, val := range vals { @@ -324,7 +324,7 @@ func processField(value string, field reflect.Value) error { field.Set(sl) case reflect.Map: mp := reflect.MakeMap(typ) - if len(strings.TrimSpace(value)) != 0 { + if strings.TrimSpace(value) != "" { pairs := strings.Split(value, ",") for _, pair := range pairs { kvpair := strings.Split(pair, ":") diff --git a/vendor/modules.txt b/vendor/modules.txt index dcfda9ebf78..ae88bc7bb68 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -285,7 +285,7 @@ github.com/mccutchen/go-httpbin/httpbin/digest # github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd ## explicit; go 1.18 github.com/mstoykov/atlas -# github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1 +# github.com/mstoykov/envconfig v1.5.0 ## explicit github.com/mstoykov/envconfig # github.com/mstoykov/k6-taskqueue-lib v0.1.0