Skip to content

Commit 0cf0aaf

Browse files
committed
fix: configure secrets before config validation
1 parent 80ea431 commit 0cf0aaf

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

cmd/root.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ var rootCmd = &cobra.Command{
2828
parseErr := viper.Unmarshal(&config)
2929
HandleError(parseErr, "Failed to parse config")
3030

31+
// Secrets
32+
log.Info().Msg("Parsing secrets")
33+
34+
config.Secret = utils.GetSecret(config.Secret, config.SecretFile)
35+
config.GithubClientSecret = utils.GetSecret(config.GithubClientSecret, config.GithubClientSecretFile)
36+
config.GoogleClientSecret = utils.GetSecret(config.GoogleClientSecret, config.GoogleClientSecretFile)
37+
config.GenericClientSecret = utils.GetSecret(config.GenericClientSecret, config.GenericClientSecretFile)
38+
3139
// Validate config
3240
log.Info().Msg("Validating config")
3341
validator := validator.New()
@@ -46,14 +54,6 @@ var rootCmd = &cobra.Command{
4654
log.Fatal().Err(usersErr).Msg("Failed to parse users")
4755
}
4856

49-
// Secrets
50-
log.Info().Msg("Parsing secrets")
51-
52-
config.Secret = utils.GetSecret(config.Secret, config.SecretFile)
53-
config.GithubClientSecret = utils.GetSecret(config.GithubClientSecret, config.GithubClientSecretFile)
54-
config.GoogleClientSecret = utils.GetSecret(config.GoogleClientSecret, config.GoogleClientSecretFile)
55-
config.GenericClientSecret = utils.GetSecret(config.GenericClientSecret, config.GenericClientSecretFile)
56-
5757
// Create oauth whitelist
5858
oauthWhitelist := strings.Split(config.OAuthWhitelist, ",")
5959
log.Debug().Strs("oauth_whitelist", oauthWhitelist).Msg("Parsed OAuth whitelist")

internal/types/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ type User struct {
1919
type Users []User
2020

2121
type Config struct {
22-
Port int `validate:"number" mapstructure:"port"`
23-
Address string `mapstructure:"address, ip4_addr"`
24-
Secret string `validate:"required,len=32" mapstructure:"secret"`
22+
Port int `mapstructure:"port"`
23+
Address string `validate:"ip4_addr" mapstructure:"address"`
24+
Secret string `validate:"len=32" mapstructure:"secret"`
2525
SecretFile string `mapstructure:"secret-file"`
2626
AppURL string `validate:"required,url" mapstructure:"app-url"`
2727
Users string `mapstructure:"users"`

0 commit comments

Comments
 (0)