-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: loading of dbUsername field for server config #2189
Conversation
38fe290
to
6aa9317
Compare
@@ -50,32 +51,6 @@ func TestServerCmd_LoadOptions(t *testing.T) { | |||
} | |||
|
|||
testCases := []testCase{ | |||
{ | |||
name: "secret providers", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case is now part of "all options from config" below.
Server string `mapstructure:"server"` | ||
Name string `mapstructure:"name"` | ||
AccessKey string `mapstructure:"accessKey"` | ||
CACert string `mapstructure:"caCert"` | ||
CAKey string `mapstructure:"caKey"` | ||
SkipTLSVerify bool `mapstructure:"skipTLSVerify"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is covered by an existing test: cmd.TestConnectorCmd
} | ||
|
||
type KeyProvider struct { | ||
Kind string `mapstructure:"kind" validate:"required"` | ||
Kind string `validate:"required"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key provider and secret provider loading is covered by:
server.TestKeyProvider_PrepareForDecode_IntegrationWithDecode_FullConfig
server.TestSecretProvider_PrepareForDecode_IntegrationWithDecode_FullConfig
@@ -8,7 +8,7 @@ import ( | |||
) | |||
|
|||
type OptionsDiffV0dot1 struct { | |||
Identities []User `mapstructure:"identities" validate:"dive"` | |||
Identities []User `validate:"dive"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Covered by cmd.TestApplyVersion0ConfigToLatest
DBHost string | ||
DBPort int | ||
DBName string | ||
DBUsername string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary fix is this one line
Add a test that covers all config fields. Also remove mapstructure tags, which were not being used since we changed to using cliopts for config loading. Co-authored-by: Bruce MacDonald <[email protected]>
9396066
to
b81a4ab
Compare
In #1755 we changed from using
mapstructure
tags to usingconfig
tags, but I forgot to remove or update all the existing struct tags.Every other field continued to work because the struct field name matched the convention. Unfortunately
dbUsername
was the one case where it did not match convention and required the struct tag. A workaround was to usedbUser
orINFRA_SERVER_DB_USER
.This PR fixes the bug by renaming the field to
DBUsername
.It also adds test coverage for every field in
server.Options
to show this is the only field with the problem.I also removed the struct tags, since they no longer do anything and keeping them would be confusing. I'll leave some inline comments for where each of the fields is tested.