Skip to content
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

Merged
merged 7 commits into from
Sep 15, 2023

Conversation

evankanderson
Copy link
Member

I spent a bit of time trying to get the env vars to work and I ended up reworking defaults as well.

Copy link
Contributor

@jhrozek jhrozek left a 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

// NoncePeriod is the period in seconds for which a nonce is valid
NoncePeriod int64 `mapstructure:"nonce_period"`
NoncePeriod int64 `mapstructure:"nonce_period" default:"60"`
Copy link
Contributor

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..

Copy link
Member Author

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"`
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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"`
Copy link
Contributor

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?

Copy link
Member Author

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!

Copy link
Member Author

@evankanderson evankanderson left a 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 {
Copy link
Contributor

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.

Copy link
Member Author

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"`
Copy link
Contributor

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.

@evankanderson evankanderson merged commit 172f54d into stacklok:main Sep 15, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants