Skip to content

Commit 60cec02

Browse files
authored
fix: Parse boolean in slice for gitauth (coder#5113)
This was causing a panic for the new `no_refesh` option!
1 parent 8e468c4 commit 60cec02

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cli/deployment/config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,11 @@ func readSliceFromViper[T any](vip *viper.Viper, key string, value any) []T {
529529
newType := reflect.Indirect(reflect.New(elementType))
530530
instance = &newType
531531
}
532-
switch instance.Field(i).Type().String() {
532+
switch v := instance.Field(i).Type().String(); v {
533533
case "[]string":
534534
value = vip.GetStringSlice(configKey)
535+
case "bool":
536+
value = vip.GetBool(configKey)
535537
default:
536538
}
537539
instance.Field(i).Set(reflect.ValueOf(value))

cli/deployment/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func TestConfig(t *testing.T) {
167167
"CODER_GITAUTH_0_TOKEN_URL": "https://token.com",
168168
"CODER_GITAUTH_0_REGEX": "github.com",
169169
"CODER_GITAUTH_0_SCOPES": "read write",
170+
"CODER_GITAUTH_0_NO_REFRESH": "true",
170171

171172
"CODER_GITAUTH_1_ID": "another",
172173
"CODER_GITAUTH_1_TYPE": "gitlab",
@@ -187,6 +188,7 @@ func TestConfig(t *testing.T) {
187188
TokenURL: "https://token.com",
188189
Regex: "github.com",
189190
Scopes: []string{"read", "write"},
191+
NoRefresh: true,
190192
}, {
191193
ID: "another",
192194
Type: "gitlab",

0 commit comments

Comments
 (0)