MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / Setup

Function Setup

pkg/config/config.go:64–87  ·  view source on GitHub ↗
(v *viper.Viper)

Source from the content-addressed store, hash-verified

62}
63
64func Setup(v *viper.Viper) error {
65 setDefaults(v)
66 if err := bindEnvironment(v); err != nil {
67 return err
68 }
69
70 configPath, err := getConfigPath()
71 if err == nil {
72 SetupConfigFile(v, configPath)
73 if err := v.ReadInConfig(); err != nil {
74 if _, ok := err.(viper.ConfigFileNotFoundError); ok {
75 // Do nothing, config file will be created on `config set` cmd
76 // This is to avoid issues with CI tools that may not have access
77 // to the file system
78 } else {
79 // Config file was found but something is wrong
80 // we can recover and run with no config
81 fmt.Println("Error reading config file: %w", err)
82 }
83 }
84 }
85 // if we can't get the configPath, then everything will just be defaulted
86 return nil
87}
88
89// EnsureConfigPath works out the config path, then creates the directory to make sure that it exists
90func EnsureConfigPath() (string, error) {

Callers 1

mainFunction · 0.92

Calls 4

setDefaultsFunction · 0.85
bindEnvironmentFunction · 0.85
getConfigPathFunction · 0.85
SetupConfigFileFunction · 0.85

Tested by

no test coverage detected