-
Notifications
You must be signed in to change notification settings - Fork 327
Conversation
Previously, we were taking any value for boolean env vars to mean "true". If someone specified `WAYPOINT_SERVER_TLS=false`, we would take that to mean true. This fixes that. Note on the implementation - I hate to be the person to introduce a generic "util" package. If anyone has any better ideas for where to put this little function, or feels like we should just strconv in-line every time, I am open to those ideas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some other examples in the documentation where WAYPOINT_SERVER_TLS_SKIP_VERIFY
is used and needs to be updated I think, should we encourage users to use true
now instead of 1
?
internal/util/env.go
Outdated
|
||
// Extracts a boolean from an env var. Falls back to the default if | ||
// The key is unset or not a valid boolean. | ||
func GetEnvBool(key string, defaultValue bool) (value bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally avoid named returns unless we're returning multiple of the same type, and naming them serves as documentation.
.changelog/1699.txt
Outdated
@@ -0,0 +1,4 @@ | |||
```release-note:improvement | |||
core: Inspect values of enviromment variables meant to be booleans |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core: Inspect values of enviromment variables meant to be booleans | |
core: Correct parsing of boolean of some environment variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with the util package!
I'd update the docs (see comments) to only be as specific as our code actually requires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got a request for tests 😄 And a suggestion for not introducing util if we don't have to
connecting to the server. | ||
- `WAYPOINT_SERVER_TLS_SKIP_VERIFY`. Current must be set to `1` to disable TLS verification | ||
- `WAYPOINT_SERVER_TLS_SKIP_VERIFY`. Current must be set to truthy value (e.g. "1") to disable TLS verification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `WAYPOINT_SERVER_TLS_SKIP_VERIFY`. Current must be set to truthy value (e.g. "1") to disable TLS verification | |
- `WAYPOINT_SERVER_TLS_SKIP_VERIFY`. Current must be set to a truthy value (e.g. "1") to disable TLS verification |
internal/env/env.go
Outdated
if envVal == "" { | ||
return defaultValue | ||
} | ||
value, err := strconv.ParseBool(envVal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's convert envVal to lower before passing it in just to support 🧽 👖 case. Dealers choice if we also support yes
/ no
.
And thereby conforming to our style guide.
Btw, this can probably be backported if you want. |
Previously, we were taking any value for boolean env vars to mean "true". If someone specified
WAYPOINT_SERVER_TLS=false
, we would take that to mean true. This fixes that.Note on the implementation - I hate to be the person to introduce a generic "util" package. If anyone has any better ideas for where to put this little function, or feels like we should just strconv in-line every time, I am open to those ideas.