-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig.go
More file actions
37 lines (29 loc) · 694 Bytes
/
config.go
File metadata and controls
37 lines (29 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"os"
"path/filepath"
"github.com/spf13/viper"
)
func (s *SSHAgent) parseConfig() (*viper.Viper, error) {
v := viper.New()
cfgPath, err := os.UserConfigDir()
if err != nil {
return v, err
}
v.AddConfigPath(".")
v.AddConfigPath(filepath.Join(cfgPath, agentName))
v.SetConfigName(agentName)
if err := v.ReadInConfig(); err != nil {
return v, err
}
/*
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
return v,fmt.Errorf("config file not found in %s, continuing as normal ssh-agent", err)
} else {
return v, fmt.Errorf("error reading config file %s", err)
}
*/
// reload config on file changes
v.WatchConfig()
return v, nil
}