From ce6cc9e18d29f635183ad87eb8f732faaa89be04 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Mon, 19 Oct 2020 19:26:29 -0400 Subject: [PATCH] Minor readability improvements --- config/config.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 06b9cbdf..069fabd8 100644 --- a/config/config.go +++ b/config/config.go @@ -16,6 +16,10 @@ const ( // DefaultConfigurationFilePath is the default path that will be used to search for the configuration file // if a custom path isn't configured through the GATUS_CONFIG_FILE environment variable DefaultConfigurationFilePath = "config/config.yaml" + + // DefaultFallbackConfigurationFilePath is the default fallback path that will be used to search for the + // configuration file if DefaultConfigurationFilePath didn't work + DefaultFallbackConfigurationFilePath = "config/config.yml" ) var ( @@ -49,6 +53,7 @@ type Config struct { Services []*core.Service `yaml:"services"` } +// Get returns the configuration, or panics if the configuration hasn't loaded yet func Get() *Config { if config == nil { panic(ErrConfigNotLoaded) @@ -56,6 +61,7 @@ func Get() *Config { return config } +// Load loads a custom configuration file func Load(configFile string) error { log.Printf("[config][Load] Reading configuration from configFile=%s", configFile) cfg, err := readConfigurationFile(configFile) @@ -70,11 +76,12 @@ func Load(configFile string) error { return nil } +// LoadDefaultConfiguration loads the default configuration file func LoadDefaultConfiguration() error { err := Load(DefaultConfigurationFilePath) if err != nil { if err == ErrConfigFileNotFound { - return Load("config/config.yml") + return Load(DefaultFallbackConfigurationFilePath) } return err }