-
Notifications
You must be signed in to change notification settings - Fork 43
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
Enable environment overrides and built-in configuration defaults #963
Conversation
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.
just a bunch of comments, in general looks good
internal/config/auth.go
Outdated
// NoncePeriod is the period in seconds for which a nonce is valid | ||
NoncePeriod int64 `mapstructure:"nonce_period"` | ||
NoncePeriod int64 `mapstructure:"nonce_period" default:"60"` |
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.
NoncePeriod is unused as of now correct? I was wondering because this new default is quite a bit lower than the original one, but git grep -I nonceperiod
only finds these two lines..
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.
Thanks, I zoned out on this one and assumed that copilot had pulled out other correct values, it had the correct one here. FIxed.
v.SetDefault("logging.level", "debug") | ||
v.SetDefault("logging.format", "json") | ||
v.SetDefault("logging.logFile", "") | ||
Level string `mapstructure:"level" default:"debug"` |
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.
I know you didn't change this default, but do you think the default log level should be debug?
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.
🤷
I'm fine with changing it, but the goal here was to make it so that the code actually had all the defaults.
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.
Not in this PR, but I was wondering if you had some thoughts about how verbose should the default deployment be based on your SaaS work.
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.
I figured we'd set the defaults to be appropriate for development work, though I could see preferring info
for that as well to avoid things being too spammy.
@@ -26,13 +26,13 @@ type AuthConfig struct { | |||
// RefreshTokenPublicKey is the public key used to verify the refresh token for authn/z | |||
RefreshTokenPublicKey string `mapstructure:"refresh_token_public_key"` | |||
// TokenExpiry is the expiry time for the access token in seconds | |||
TokenExpiry int64 `mapstructure:"token_expiry"` | |||
TokenExpiry int64 `mapstructure:"token_expiry" default:"3600"` |
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.
Do you think the other fields could also use defaults?
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.
Huh, I somehow lost just that one file in my commit. I suspect I hadn't saved the buffer.
Fixed!
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.
I also realized that webhook-config
and github
entries in config.yaml
aren't going through our structure yet, so I reverted the webhook change.
} | ||
|
||
// GetCryptoConfigWithDefaults returns a CryptoConfig with default values | ||
// TODO: extract from struct default tags | ||
func GetCryptoConfigWithDefaults() CryptoConfig { |
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.
It might be nice to rename this function in a future patch, currently it's used only in tests and returns DefaultConfigForTest
, but the name sounds like non-test function.
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.
Ooops, I do extract this from struct tags now, and you're right, I should either remove this and have the tests use DefaultConfigForTest
or name this ForTest
.
v.SetDefault("logging.level", "debug") | ||
v.SetDefault("logging.format", "json") | ||
v.SetDefault("logging.logFile", "") | ||
Level string `mapstructure:"level" default:"debug"` |
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.
Not in this PR, but I was wondering if you had some thoughts about how verbose should the default deployment be based on your SaaS work.
I spent a bit of time trying to get the env vars to work and I ended up reworking defaults as well.