Skip to content

Commit a30c2f2

Browse files
authored
[feature flag] respect env-var of feature flag (even if turned off) and default enable Nixpkg Version FF (#266)
## Summary 1. The Feature Flag library should respect the value of the env-var, whether ON or OFF. 2. Turn on the default value of the nixpkgs version FF. ## How was it tested? For change #1: respecting the env-var: ``` > DEVBOX_FEATURE_NIXPKG_VERSION=0 DEVBOX_DEBUG=1 devbox shell > git status # saw no changes to devbox.json as expected ``` For change #2: enabling the nixpkgs version ``` > devbox shell > git status # saw changes to devbox.json that adds the default commit hash ```
1 parent 2118019 commit a30c2f2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

boxcli/featureflag/feature.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ func (f *feature) Enabled() bool {
3030
if f == nil {
3131
return false
3232
}
33-
if on, _ := strconv.ParseBool(os.Getenv("DEVBOX_FEATURE_" + f.name)); on {
34-
debug.Log("Feature %q enabled via environment variable.", f.name)
35-
return true
33+
if on, err := strconv.ParseBool(os.Getenv("DEVBOX_FEATURE_" + f.name)); err == nil {
34+
status := "enabled"
35+
if !on {
36+
status = "disabled"
37+
}
38+
debug.Log("Feature %q %s via environment variable.", f.name, status)
39+
return on
3640
}
3741
return f.enabled
3842
}

boxcli/featureflag/nixpkgversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package featureflag
33
const NixpkgVersion = "NIXPKG_VERSION"
44

55
func init() {
6-
disabled(NixpkgVersion)
6+
enabled(NixpkgVersion)
77
}

0 commit comments

Comments
 (0)