Skip to content

Commit 8e86eab

Browse files
committed
fix(clibase): allow empty values to unset defaults
1 parent f88f273 commit 8e86eab

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

cli/clibase/option.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,7 @@ func (s *OptionSet) ParseEnv(vs []EnvVar) error {
121121
}
122122

123123
envVal, ok := envs[opt.Env]
124-
// Currently, empty values are treated as if the environment variable is
125-
// unset. This behavior is technically not correct as there is now no
126-
// way for a user to change a Default value to an empty string from
127-
// the environment. Unfortunately, we have old configuration files
128-
// that rely on the faulty behavior.
129-
if !ok || envVal == "" {
124+
if !ok {
130125
continue
131126
}
132127

cli/clibase/option_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestOptionSet_ParseEnv(t *testing.T) {
9797
require.EqualValues(t, "foo", workspaceName)
9898
})
9999

100-
t.Run("EmptyValue", func(t *testing.T) {
100+
t.Run("EmptyValueUnsets", func(t *testing.T) {
101101
t.Parallel()
102102

103103
var workspaceName clibase.String
@@ -116,6 +116,6 @@ func TestOptionSet_ParseEnv(t *testing.T) {
116116

117117
err = os.ParseEnv(clibase.ParseEnviron([]string{"CODER_WORKSPACE_NAME="}, "CODER_"))
118118
require.NoError(t, err)
119-
require.EqualValues(t, "defname", workspaceName)
119+
require.EqualValues(t, "", workspaceName)
120120
})
121121
}

coder.env

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Coder must be reachable from an external URL for users and workspaces to connect.
22
# e.g. https://coder.example.com
3-
CODER_ACCESS_URL=
3+
# CODER_ACCESS_URL=
44

5-
CODER_ADDRESS=
6-
CODER_PG_CONNECTION_URL=
7-
CODER_TLS_CERT_FILE=
8-
CODER_TLS_ENABLE=
9-
CODER_TLS_KEY_FILE=
5+
# CODER_ADDRESS=
6+
# CODER_PG_CONNECTION_URL=
7+
# CODER_TLS_CERT_FILE=
8+
# CODER_TLS_ENABLE=
9+
# CODER_TLS_KEY_FILE=
1010

1111
# Run "coder server --help" for flag information.

0 commit comments

Comments
 (0)