diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index a231e8337..ce8393f9b 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -130,7 +130,7 @@ func init() { RootCmd.PersistentFlags().BoolVarP(&cachevar, "no-cache", "c", false, "no caching") RootCmd.PersistentFlags().StringVarP(&outputFormat, "output", "o", "yaml", "output format yaml or json") - RootCmd.PersistentFlags().BoolVarP(&debugSwitch, "debug", "d", false, "enable debug level output") + RootCmd.PersistentFlags().BoolVarP(&debugSwitch, "verbose", "d", false, "enable verbose output") cobra.EnableCommandSorting = false cobra.EnablePrefixMatching = prefixMatching diff --git a/pkg/cmd/ssh_aws.go b/pkg/cmd/ssh_aws.go index 61fd753d2..6d736fcb9 100644 --- a/pkg/cmd/ssh_aws.go +++ b/pkg/cmd/ssh_aws.go @@ -92,7 +92,12 @@ func sshToAWSNode(nodeName, path, user, pathSSKeypair string, sshPublicKey []byt fmt.Print("SSH " + bastionNode + " => " + node + "\n") key := filepath.Join(pathSSKeypair, "key") - sshCmd := fmt.Sprintf("ssh -i " + key + " -o ConnectionAttempts=2 -o \"ProxyCommand ssh -W %%h:%%p -i " + key + " -o IdentitiesOnly=yes -o ConnectionAttempts=2 -o StrictHostKeyChecking=no " + bastionNode + "\" " + node + " -o IdentitiesOnly=yes -o StrictHostKeyChecking=no") + var sshCmd string + if debugSwitch { + sshCmd = fmt.Sprintf("ssh -v -i " + key + " -o ConnectionAttempts=2 -o \"ProxyCommand ssh -W %%h:%%p -i " + key + " -o IdentitiesOnly=yes -o ConnectionAttempts=2 -o StrictHostKeyChecking=no " + bastionNode + "\" " + node + " -o IdentitiesOnly=yes -o StrictHostKeyChecking=no") + } else { + sshCmd = fmt.Sprintf("ssh -i " + key + " -o ConnectionAttempts=2 -o \"ProxyCommand ssh -W %%h:%%p -i " + key + " -o IdentitiesOnly=yes -o ConnectionAttempts=2 -o StrictHostKeyChecking=no " + bastionNode + "\" " + node + " -o IdentitiesOnly=yes -o StrictHostKeyChecking=no") + } cmd := exec.Command("bash", "-c", sshCmd) cmd.Stdout = os.Stdout cmd.Stdin = os.Stdin diff --git a/pkg/cmd/utils.go b/pkg/cmd/utils.go index 9c1f43bba..f0fa07a98 100644 --- a/pkg/cmd/utils.go +++ b/pkg/cmd/utils.go @@ -17,9 +17,11 @@ package cmd import ( "fmt" "io/ioutil" + "log" "os" "os/exec" "path/filepath" + "runtime" "strings" gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1" @@ -34,8 +36,14 @@ import ( // checkError checks if an error during execution occurred func checkError(err error) { if err != nil { - fmt.Println(err.Error()) - os.Exit(2) + if debugSwitch { + _, fn, line, _ := runtime.Caller(1) + log.Printf("[error] %s:%d \n %v", fn, line, err) + os.Exit(2) + } else { + fmt.Println(err.Error()) + os.Exit(2) + } } }