Skip to content

Commit

Permalink
Make some config values required
Browse files Browse the repository at this point in the history
  • Loading branch information
giodamelio committed Apr 25, 2023
1 parent 2899760 commit 0720705
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ func loadConfig() {
if err != nil {
log.Fatal().Err(err).Str("path", configPath).Msg("could not parse conf file")
}

// Check for required config options
requiredConfigs := []string{"domain", "tailscale.organization-name"}
var missingConfigs []string
for _, requiredConfigName := range requiredConfigs {
if !viper.IsSet(requiredConfigName) {
missingConfigs = append(missingConfigs, requiredConfigName)
}
}
if len(missingConfigs) != 0 {
log.Fatal().Msgf("Missing required config values:\n - %s\n", strings.Join(missingConfigs, "\n - "))
}
}

0 comments on commit 0720705

Please sign in to comment.