-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Env variable DURATION is being used implicitly #671
Comments
Thanks for reporting this! It is supposed to be |
@na-- just discovered that there is the same issue with |
Hi @na-- just checked |
I guess that means we should just replace or fork the library, since there has also been no progress on the issue I submitted in it's github (about unnecessarily initializing empty struct pointers) |
Hello @na--, any progress in replacing/forking the library? (sorry for somehow hijacking this thread) |
@marco-m you're not hijacking the thread, unfortunately this hasn't been a big priority recently and we haven't made any progress in replacing or forking the original library 😞 At this point, I'd say that we're very unlikely to fork it, since it has at least 2 major architectural decisions (this issue and linked one about unnecessary initialization of struct pointers) that we disagree with and consider bugs. We'll likely either use another library or write something very simple ourselves to replace it - I think we just need something that reads struct tags (to get the environment variable name) and knows how to work with simple types and |
Thanks for the update @na-- ! |
As explained in the upstream issue this is the expected behaviour
package main
import (
"fmt"
"github.com/kelseyhightower/envconfig"
)
type ImplicitTest struct {
UserName string `split_words:"true"`
}
type ExplicitTest struct {
UserName string `envconfig:"USER_NAME"`
}
func main() {
implicitTest := ImplicitTest{}
envconfig.MustProcess("my_app", &implicitTest)
fmt.Printf("The value of ImplicitTest.UserName: \"%s\"\n", implicitTest.UserName)
explicitTest := ExplicitTest{}
envconfig.MustProcess("my_app", &explicitTest)
fmt.Printf("The value of ExplicitTest.UserName: \"%s\"\n", explicitTest.UserName)
} $ USER_NAME=pesho go run main.go
The value of ImplicitTest.UserName: ""
The value of ExplicitTest.UserName: "pesho"
$ MY_APP_USER_NAME=pesho go run main.go
The value of ImplicitTest.UserName: "pesho"
The value of ExplicitTest.UserName: "pesho" If we agree this is okay I might try to do a fast sweep through the code possibly with $ rg -g "*.go" 'envconfig:"' --count-matches
lib/runtime_options.go:2
lib/options.go:34
cmd/config.go:5
stats/csv/config.go:4
stats/datadog/collector.go:1
stats/cloud/config.go:18
stats/influxdb/config.go:12
stats/kafka/config.go:8
stats/statsd/common/config.go:4 |
Also ... obviously we can just set I don't think we have any use case for not doing it that way ... and it will probably be much easier ... |
Hmm yeah, if we just set the struct tags to Long term I'd still want to replace the |
Works on #671 and fixing it in almost all cases. This was done primarily by running: ``` rg -g "*.go" 'envconfig:"' --files-with-matches |\ xargs -n 1 sed -s -i 's/envconfig:"/envconfig:"K6_/g' ``` And than manually fixing all remaing problems by hand. In the mean time I found out we weren't properly combing the configuration for statsd/datadog and fixed. Also renamed HttpDebug to HTTPDebug in the Options struct. Unfortunately due to the way the statsd and datadog share the same struct for a config this doesn't fix the issue as a whole for them.
* Prefix all envconfig struct tags with K6 directly Works on #671 and fixing it in almost all cases. This was done primarily by running: ``` rg -g "*.go" 'envconfig:"' --files-with-matches |\ xargs -n 1 sed -s -i 's/envconfig:"/envconfig:"K6_/g' ``` And than manually fixing all remaing problems by hand. In the mean time I found out we weren't properly combing the configuration for statsd/datadog and fixed. Also uppercases all the envconfig struct tags using: ``` rg -g "*.go" 'envconfig:"' --files-with-matches |\ xargs -n 1 sed -r -i -s 's/envconfig:"([^"]*)"/envconfig:"\U\1\E"/g' ``` Renamed HttpDebug to HTTPDebug in the Options struct. Unfortunately due to the way the statsd and datadog share the same struct for a config this doesn't fix the issue as a whole for them.
After #1215 in order to completely consider this fixed the config struct for statsd and datadog outputs should be split in two. |
I've bumped into this accidentally:
If global environment variable DURATION is set, it is being used by k6 to parse duration value.
In my case I wanted to execute k6 script with following command:
k6 run --vus 2 --duration 60s <script_name.js>
But also I had a global environment variable DURATION=60, and as result my execution kept failing with
I didn't find any mentions about DURATION in docs:
https://docs.k6.io/docs/running-k6
https://docs.k6.io/docs/environment-variables
https://docs.k6.io/docs/execution-context-variables
The text was updated successfully, but these errors were encountered: