feat(cli): handle a few environment variables with correct order of precedence#195
Conversation
|
@skevetter none of the checks are triggered by a pull request now, while before most of them were (I think). Is this change intentional? Thanks! |
For the (brief) moment, yes. I am refactoring the workflows to better support code contributions and releases. |
f72ad49 to
f42ac8a
Compare
Thank you so much!! |
c97e278 to
3632fc5
Compare
Thank you for your patience. I think I have the workflows in a better place now. |
cmd/flags/flags.go
Outdated
| // Defines a string flag with specified name, environment variable, default value, and usage string. | ||
| // The argument p points to a string variable in which to store the value of the flag. | ||
| func StringVarE(f *flag.FlagSet, p *string, name string, env string, value string, usage string) { | ||
| key := "DEVPOD_" + env |
There was a problem hiding this comment.
minor: I would make DEVPOD_ into a re-usable constant like DevpodEnvPrefix
cmd/flags/flags.go
Outdated
| if err == nil { | ||
| return result | ||
| } | ||
| return def |
There was a problem hiding this comment.
question: Should the error fail silently or should we log it here? And check if error is not nil first
if err != nil {
log.Warnf("invalid boolean value %s for key %s, falling back to default %v", value, key, default)
return default
}
cmd/flags/flags.go
Outdated
| f.BoolVar(p, name, GetBoolEnv(key, value), usage+". You can also use "+key+" to set this") | ||
| } | ||
|
|
||
| func GetBoolEnv(key string, def bool) bool { |
There was a problem hiding this comment.
opinion: default or defaultValue in lieu of def for clarity
cmd/flags/flags.go
Outdated
|
|
||
| // Defines a string flag with specified name, environment variable, default value, and usage string. | ||
| // The argument p points to a string variable in which to store the value of the flag. | ||
| func StringVarE(f *flag.FlagSet, p *string, name string, env string, value string, usage string) { |
There was a problem hiding this comment.
optional: if you can think of a more recognizable value for p *string, it may be helpful to future readers. And same for value, if it is intended to be a default/fallback value then perhaps use defaultValue.
cmd/flags/flags.go
Outdated
| flags.StringVar(&globalFlags.Provider, "provider", "", "The provider to use. Needs to be configured for the selected context.") | ||
| flags.BoolVar(&globalFlags.Debug, "debug", false, "Prints the stack trace if an error occurs") | ||
| flags.BoolVar(&globalFlags.Silent, "silent", false, "Run in silent mode and prevents any devpod log output except panics & fatals") | ||
| StringVarE(flags, &globalFlags.LogOutput, "log-output", "LOG_OUTPUT", "plain", "The log format to use. Can be either plain, raw or json") |
There was a problem hiding this comment.
question: wrt comment above, perhaps the prefix would be more visible here as DEVPOD_ENV_PREFIX+VAL (e.g., DEVPOD_ENV_PREFIX+LOG_OUTPUT). Thoughts?
Thank you! |
…recedence Signed-off-by: Leonid Dubinsky <dub@podval.org>
Signed-off-by: Leonid Dubinsky <dub@podval.org>
cf13c4f to
d77b18b
Compare
Great work! Let me know if you encounter any pain points or have any general feedback. My intent is for contribution process to be streamlined and frictionless for both contributors and reviewers. Also, if you're interested in being a reviewer, let me know. I would be more than happy to share the work :) |
Thank you!
Thanks!
Great!
I am honored by this offer, but this being a new code-base in a new programming language for me, I do not yet feel confident enough to accept it. We'll see how it goes ;) |
Delete. To keep things tidy.
I will have to get back to you on that. There has been a number of dependency upgrades (go, rust, node), upgrading the go version, etc.
Possibly this. If you see This may be a build configuration issue I need to investigate. The application is compiled with
still on my todo list
no worries |
I do not think the build picks up ambient version - it is 2.42 on the machine where I build. If this is a result of the changes to the build/dependencies, it would be nice to make it a bit more flexible...
no pressure ;) |
|
what do I need to do for this to get merged? |
Nothing on your end. A recent upgrade to tauri v2 messed with some of the artifacts that get built in the release. Once I have that resolved, this change will be merged. |
|
Thank you! |
first steps in the direction of #196...