github.com/secure-build/gitlab-runner@v12.5.0+incompatible/helpers/cli/fix_home.go (about) 1 package cli_helpers 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/docker/docker/pkg/homedir" 8 "github.com/urfave/cli" 9 ) 10 11 func FixHOME(app *cli.App) { 12 appBefore := app.Before 13 14 app.Before = func(c *cli.Context) error { 15 // Fix home 16 if key := homedir.Key(); os.Getenv(key) == "" { 17 value := homedir.Get() 18 if value == "" { 19 return fmt.Errorf("the %q is not set", key) 20 } 21 os.Setenv(key, value) 22 } 23 24 if appBefore != nil { 25 return appBefore(c) 26 } 27 return nil 28 } 29 }