Allow keyfile to be absolute path

This commit is contained in:
Jae Kwon 2017-05-21 19:51:28 -07:00
parent bd62b21d6e
commit 2983f5018b
1 changed files with 7 additions and 2 deletions

View File

@ -89,8 +89,13 @@ func genKey() *Key {
}
func LoadKey(keyFile string) (*Key, error) {
rootDir := viper.GetString(cli.HomeFlag)
filePath := path.Join(rootDir, keyFile)
filePath := keyFile
if !strings.HasPrefix(keyFile, "/") && !strings.HasPrefix(keyFile, ".") {
rootDir := viper.GetString(cli.HomeFlag)
filePath = path.Join(rootDir, keyFile)
}
keyJSONBytes, err := ioutil.ReadFile(filePath)
if err != nil {
return nil, err