Enable env var hints for --token#945
Conversation
Integralist
left a comment
There was a problem hiding this comment.
👋🏻 @andersjanmyr thanks for opening this PR!
Implementation looks OK, I just have a few requests.
pkg/app/run.go
Outdated
| envVarCache = []string{} | ||
| for _, e := range os.Environ() { | ||
| pair := strings.SplitN(e, "=", 2) | ||
| envVarCache = append(envVarCache, fmt.Sprintf("\\$%s", pair[0])) |
There was a problem hiding this comment.
I have concerns about Windows support, it would be good to see a test implemented for the env package that validates the logic will work for Windows users. Our CI runs the CLI test suite on all three major platforms: macOS, Linux and Windows so if the test passes on all three then we'll know the implementation is good.
Example: set some environment variables and see if this function returns back the expected list of variables.
On Windows, I believe, the way to reference an environment variable is %VAR_NAME% so I presume os.Environ() will normalize the output so it works across platforms.
There was a problem hiding this comment.
Yes, it probably needs some special treatment to handle Windows.
|
@andersjanmyr out of interest, is there a reason you're using this approach rather than something like |
|
@Integralist I was thinking of using profile locally, but we're using the same script to deploy both locally and on CI. |
45199e1 to
0ed90f8
Compare
Integralist
left a comment
There was a problem hiding this comment.
Other than two minor change requests this looks good to me.
Thanks!
Moved envVars to env.Vars Add test case for env.Vars Add slices package for slices.Contains Actually test something sensible Check error value from Setenv since windows does not set values Test with common variables instead Mark tests on other platforms as skip Document Vars method
0ed90f8 to
efda6dc
Compare
Example: