コード例 #1
0
ファイル: db_tunnel.go プロジェクト: Zyko0/cli
     >

   We are looking if an SSH-agent is running on your host, otherwise we are
   using the SSH key '$HOME/.ssh/id_rsa'. You can specify a precise SSH key
   you want to use to authenticate thanks to the '-i' flag.

   Example
     $ scalingo -a rails-app db-tunnel -i ~/.ssh/custom_key DATABASE_URL`,
		Action: func(c *cli.Context) {
			currentApp := appdetect.CurrentApp(c)
			var sshIdentity string
			if c.String("identity") == "" && os.Getenv("SSH_AUTH_SOCK") != "" {
				sshIdentity = "ssh-agent"
			} else if c.String("identity") == "" {
				sshIdentity = sshkeys.DefaultKeyPath
			} else {
				sshIdentity = c.String("identity")
			}
			if len(c.Args()) != 1 {
				cli.ShowCommandHelp(c, "db-tunnel")
			} else if err := db.Tunnel(currentApp, c.Args()[0], sshIdentity, c.Int("port")); err != nil {
				errorQuit(err)
			}
		},
		BashComplete: func(c *cli.Context) {
			autocomplete.CmdFlagsAutoComplete(c, "db-tunnel")
			autocomplete.DbTunnelAutoComplete(c)
		},
	}
)
コード例 #2
0
ファイル: db_tunnel.go プロジェクト: carriercomm/cli-8
			var sshIdentity string
			if c.String("identity") == "" && os.Getenv("SSH_AUTH_SOCK") != "" {
				sshIdentity = "ssh-agent"
			} else if c.String("identity") == "" {
				sshIdentity = sshkeys.DefaultKeyPath
			} else {
				sshIdentity = c.String("identity")
			}
			if len(c.Args()) != 1 {
				cli.ShowCommandHelp(c, "db-tunnel")
				return
			}
			opts := db.TunnelOpts{
				App:       currentApp,
				DBEnvVar:  c.Args()[0],
				Identity:  sshIdentity,
				Port:      c.Int("port"),
				Reconnect: c.BoolT("reconnect"),
			}
			err := db.Tunnel(opts)
			if err != nil {
				errorQuit(err)
			}
		},
		BashComplete: func(c *cli.Context) {
			autocomplete.CmdFlagsAutoComplete(c, "db-tunnel")
			autocomplete.DbTunnelAutoComplete(c)
		},
	}
)