From 2983f5018b11476623b295b0001d33eccf784942 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Sun, 21 May 2017 19:51:28 -0700 Subject: [PATCH] Allow keyfile to be absolute path --- cmd/commands/key.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/commands/key.go b/cmd/commands/key.go index d0d2009d8..4f0b25381 100644 --- a/cmd/commands/key.go +++ b/cmd/commands/key.go @@ -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