Skip to content

Commit b90a2aa

Browse files
authored
[cleanup] remove launched flags for UnifiedEnv and Lockfile; remove Disabled method (#1152)
## Summary 1. This PR removes the Disabled method. I had added it a while back after missing a `not` operator in `!featureflag.<flag name>.Enabled()` and wanted to make it explicit. @mikeland86 objected saying he prefers "one way to do things" over "more natural language". I no longer care to argue this case, so removing. 2. We've launched UnifiedEnv and Lockfile, so can remove these flags. ## How was it tested? did not test except to see that it compiles.
1 parent 7648993 commit b90a2aa

File tree

9 files changed

+10
-37
lines changed

9 files changed

+10
-37
lines changed

internal/boxcli/featureflag/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
package featureflag
55

6-
var Auth = enabled("AUTH")
6+
var Auth = enable("AUTH")

internal/boxcli/featureflag/feature.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ type feature struct {
1818

1919
var features = map[string]*feature{}
2020

21-
func disabled(name string) *feature {
21+
func disable(name string) *feature {
2222
if features[name] == nil {
2323
features[name] = &feature{name: name}
2424
}
2525
features[name].enabled = false
2626
return features[name]
2727
}
2828

29-
func enabled(name string) *feature {
29+
func enable(name string) *feature {
3030
if features[name] == nil {
3131
features[name] = &feature{name: name}
3232
}
@@ -54,10 +54,6 @@ func (f *feature) Enabled() bool {
5454
return f.enabled
5555
}
5656

57-
func (f *feature) Disabled() bool {
58-
return !f.Enabled()
59-
}
60-
6157
// All returns a map of all known features flags and whether they're enabled.
6258
func All() map[string]bool {
6359
m := make(map[string]bool, len(features))

internal/boxcli/featureflag/feature_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ import (
1111

1212
func TestEnabledFeature(t *testing.T) {
1313
name := "TestEnabledFeature"
14-
enabled(name)
14+
enable(name)
1515
if !features[name].Enabled() {
1616
t.Errorf("got %s.Enabled() = false, want true.", name)
1717
}
1818
}
1919

2020
func TestDisabledFeature(t *testing.T) {
2121
name := "TestDisabledFeature"
22-
disabled(name)
22+
disable(name)
2323
if features[name].Enabled() {
2424
t.Errorf("got %s.Enabled() = true, want false.", name)
2525
}
2626
}
2727

2828
func TestEnabledFeatureEnv(t *testing.T) {
2929
name := "TestEnabledFeatureEnv"
30-
disabled(name)
30+
disable(name)
3131
t.Setenv(envir.DevboxFeaturePrefix+name, "1")
3232
if !features[name].Enabled() {
3333
t.Errorf("got %s.Enabled() = false, want true.", name)

internal/boxcli/featureflag/lockfile.go

Lines changed: 0 additions & 3 deletions
This file was deleted.

internal/boxcli/featureflag/prompt_hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ package featureflag
22

33
// PromptHook controls the insertion of a shell prompt hook that invokes
44
// devbox shellenv, in lieu of using binary wrappers.
5-
var PromptHook = disabled("PROMPT_HOOK")
5+
var PromptHook = disable("PROMPT_HOOK")

internal/boxcli/featureflag/remove_nixpkgs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ package featureflag
44
// It leverages the search index to directly map <package>@<version> to
55
// the /nix/store/<hash>-<package>-<version> that can be fetched from
66
// cache.nixpkgs.org.
7-
var RemoveNixpkgs = disabled("REMOVE_NIXPKGS")
7+
var RemoveNixpkgs = disable("REMOVE_NIXPKGS")

internal/boxcli/featureflag/script_exit_on_error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ package featureflag
55

66
// ScriptExitOnError controls whether scripts defined in devbox.json
77
// and executed via `devbox run` should exit if any command within them errors.
8-
var ScriptExitOnError = disabled("SCRIPT_EXIT_ON_ERROR")
8+
var ScriptExitOnError = disable("SCRIPT_EXIT_ON_ERROR")

internal/boxcli/featureflag/unified_env.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

internal/lock/lockfile.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/samber/lo"
1414
"go.jetpack.io/devbox/internal/boxcli/featureflag"
15+
1516
"go.jetpack.io/devbox/internal/cuecfg"
1617
"go.jetpack.io/devbox/internal/devpkg"
1718
)
@@ -145,11 +146,6 @@ func (l *File) ResolveToCurrentNixpkgCommitHash(pkg string) error {
145146
}
146147

147148
func (l *File) Save() error {
148-
// Never write lockfile if versioned packages is not enabled
149-
if !featureflag.LockFile.Enabled() {
150-
return nil
151-
}
152-
153149
return cuecfg.WriteFile(lockFilePath(l.devboxProject), l)
154150
}
155151

@@ -185,8 +181,5 @@ func lockFilePath(project devboxProject) string {
185181
}
186182

187183
func getLockfileHash(project devboxProject) (string, error) {
188-
if !featureflag.LockFile.Enabled() {
189-
return "", nil
190-
}
191184
return cuecfg.FileHash(lockFilePath(project))
192185
}

0 commit comments

Comments
 (0)