From 07207058b7c3ecd4d27fd2b2f81e1fc4b9d0daec Mon Sep 17 00:00:00 2001 From: Giovanni d'Amelio Date: Mon, 24 Apr 2023 17:24:44 -0700 Subject: [PATCH] Make some config values required --- config.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config.go b/config.go index 6882586..69fdf4b 100644 --- a/config.go +++ b/config.go @@ -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 - ")) + } }