markwallsgrove / ec2.cli

Generate SSH aliases for EC2 machines
3 stars 1 forks source link

SSH autocompletion not working (EnvAccessKeyNotFound error) with a non-default profile #31

Closed rgoj closed 8 years ago

rgoj commented 8 years ago

When I create a profile and try to use ssh autocompletion, I get the EnvAccessKeyNotFound error.

Is this a bug or a user error?

$ ec2.cli --profile "shared" set awsAccessKey ***
$ ec2.cli --profile "shared" set awsSecretKey ***
$ ec2.cli --profile "shared" set user roman.goj
$ cat ~/.ec2.cli/config/shared.json
{
    "user": "roman.goj",
    "awsAccessKey": "***",
    "awsSecretKey": "***"
}
$ ec2.cli --profile "shared" ssh <TAB> panic: EnvAccessKeyNotFound: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment

goroutine 1 [running]:
main.main.func10(0xc8200c4ea0)
    /Users/mark/workspace/src/github.com/markwallsgrove/alias_ec2/main.go:702 +0x210
github.com/codegangsta/cli.ShowCommandCompletions(0xc8200c4ea0, 0x6634a0, 0x3)
    /Users/mark/workspace/src/github.com/codegangsta/cli/help.go:170 +0x61
github.com/codegangsta/cli.checkCommandCompletions(0xc8200c4ea0, 0x6634a0, 0x3, 0xc820018660)
    /Users/mark/workspace/src/github.com/codegangsta/cli/help.go:243 +0x76
github.com/codegangsta/cli.Command.Run(0x6634a0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6d62f0, 0x16, 0x0, ...)
    /Users/mark/workspace/src/github.com/codegangsta/cli/command.go:131 +0xfcf
github.com/codegangsta/cli.(*App).Run(0xc8200c4b40, 0xc82000a140, 0x5, 0x5, 0x0, 0x0)
    /Users/mark/workspace/src/github.com/codegangsta/cli/app.go:179 +0x1169
main.main()
    /Users/mark/workspace/src/github.com/markwallsgrove/alias_ec2/main.go:712 +0x1052

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:1721 +0x1
rgoj commented 8 years ago

This works fine though (without quotation marks):

ec2.cli --profile shared ssh <TAB>
markwallsgrove commented 8 years ago

This issue is related to the use of double quotes around the profile name. Code will need to be added to trim any double quotes from around the string.