func getRegistry(context *cli.Context) *registry.Registry { tun := getTunnelFlag(context) endpoint := context.GlobalString("endpoint") machines := []string{endpoint} client := etcd.NewClient(machines) if tun != "" { sshClient, err := ssh.NewSSHClient("core", tun) if err != nil { panic(err) } dial := func(network, addr string) (net.Conn, error) { tcpaddr, err := net.ResolveTCPAddr(network, addr) if err != nil { return nil, err } return sshClient.DialTCP(network, nil, tcpaddr) } tr := http.Transport{ Dial: dial, TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, } client.SetTransport(&tr) } return registry.New(client) }
func getTunnelFlag(context *cli.Context) string { tun := context.GlobalString("tunnel") if tun != "" && !strings.Contains(tun, ":") { tun += ":22" } return tun }