feat: support "1" for environment variables#8246
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
|
I'm not sure why the quickstart test failed - I don't see any errors in the logs, it just seems to have died. |
|
I didn't understand either (on main). So But couldn't figure out what happened to make it appear. |
55a8b1e to
649c283
Compare
|
Rebased |
|
I agree! Would you like me instead to work on supporting those? |
|
I'd loe to have you do those, but finish this first, it's a good thing, and I think env-based control will still be valuable. |
rfay
left a comment
There was a problem hiding this comment.
I manually tested and did fine, and the code looks fine. But why isEnvTrue() and IsEnvTrue()?
| // has a value accepted by strconv.ParseBool. | ||
| // This duplicates nodeps.IsEnvTrue() because pkg/nodeps imports pkg/output | ||
| // (via wsl.go), creating an import cycle if we import nodeps here. | ||
| func isEnvTrue(envVar string) bool { |
There was a problem hiding this comment.
Why do we need this duplicate of IsEnvTrue()?
There was a problem hiding this comment.
There's the import cycle mentioned in the comment. Is there some other way I could fix this?
5802773 to
2998ed6
Compare
|
Hate those import cycles!!! I guess that's the only thing I hate about go! |
|
This comment is from Claude Code (AI assistant), at the request of @rfay. Looking at the import cycle that forced the duplication of
output.UserErr.Warnf("Unable to get WSL2 networking mode: %v", err)This creates the cycle: The fix is to have func IsWSL2MirroredMode() (bool, error) {
if !IsWSL2() {
return false, nil
}
mode, err := GetWSL2NetworkingMode()
if err != nil {
return false, err
}
return mode == "mirrored", nil
}The caller (in a higher-level package that is allowed to import |
|
I imagine that conflicts with #8262 but it can be fixed there. OK to solve this problem in this PR. It's poor existing usage I think. |
Add nodeps.IsEnvTrue() helper that treats both "true" and "1" as truthy, matching common Unix conventions. Applied to DDEV_DEBUG, DDEV_VERBOSE, DDEV_NO_INSTRUMENTATION, and DDEV_NONINTERACTIVE. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2998ed6 to
3851b5a
Compare
|
Changes:
|
|
Thank you both for picking this up! |
The Issue
I keep trying to use
DDEV_VERBOSE=1instead oftrueas I use it just rarely enough to remember. It's pretty common for variables in shells use 0 / 1, so let's support that here! Feel free to close this if you think it's overcomplicated.How This PR Solves The Issue
Updates all user-facing environment variables to support
1as well astrue.AI generated, but human reviewed and tested.
Manual Testing Instructions
Try
DDEV_VERBOSE=1 ddev start ...Automated Testing Overview
Adds an automated test to cover the new behaviour.