From c55f4fd0e02a870f6edc23c07b61fc8293799599 Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Tue, 23 Jul 2019 16:55:32 +0200 Subject: Cleanup commands/config.go --- commands/config.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/commands/config.go b/commands/config.go index de927d6e..3d29a8fb 100644 --- a/commands/config.go +++ b/commands/config.go @@ -7,6 +7,8 @@ import ( "path/filepath" "strings" + "github.com/sirupsen/logrus" + "gitlab.com/gitlab-org/gitlab-runner/common" "gitlab.com/gitlab-org/gitlab-runner/network" ) @@ -55,7 +57,7 @@ func (c *configOptions) touchConfig() error { func (c *configOptions) RunnerByName(name string) (*common.RunnerConfig, error) { if c.config == nil { - return nil, fmt.Errorf("Config has not been loaded") + return nil, fmt.Errorf("config has not been loaded") } for _, runner := range c.config.Runners { @@ -64,7 +66,7 @@ func (c *configOptions) RunnerByName(name string) (*common.RunnerConfig, error) } } - return nil, fmt.Errorf("Could not find a runner with the name '%s'", name) + return nil, fmt.Errorf("could not find a runner with the name '%s'", name) } type configOptionsWithListenAddress struct { @@ -97,7 +99,10 @@ func (c *configOptionsWithListenAddress) listenAddress() (string, error) { func init() { configFile := os.Getenv("CONFIG_FILE") if configFile == "" { - os.Setenv("CONFIG_FILE", getDefaultConfigFile()) + err := os.Setenv("CONFIG_FILE", getDefaultConfigFile()) + if err != nil { + logrus.WithError(err).Fatal("Couldn't set CONFIG_FILE environment variable") + } } network.CertificateDirectory = getDefaultCertificateDirectory() -- cgit v1.2.3 From 9aa5aa2ed3ebe5aa3bee6261c8b454930265ff2f Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Tue, 23 Jul 2019 16:56:16 +0200 Subject: Remove unused method from commands/config.go --- commands/config.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/commands/config.go b/commands/config.go index 3d29a8fb..7f2eddca 100644 --- a/commands/config.go +++ b/commands/config.go @@ -41,20 +41,6 @@ func (c *configOptions) loadConfig() error { return nil } -func (c *configOptions) touchConfig() error { - // try to load existing config - err := c.loadConfig() - if err != nil { - return err - } - - // save config for the first time - if !c.config.Loaded { - return c.saveConfig() - } - return nil -} - func (c *configOptions) RunnerByName(name string) (*common.RunnerConfig, error) { if c.config == nil { return nil, fmt.Errorf("config has not been loaded") -- cgit v1.2.3