lfsapi: export SSHResolver and property

This commit is contained in:
risk danger olson 2017-03-23 13:48:52 -06:00
parent ad2b9ef704
commit 34e8c01baa
3 changed files with 11 additions and 9 deletions

@ -18,7 +18,7 @@ var UserAgent = "git-lfs"
const MediaType = "application/vnd.git-lfs+json; charset=utf-8" const MediaType = "application/vnd.git-lfs+json; charset=utf-8"
func (c *Client) NewRequest(method string, e Endpoint, suffix string, body interface{}) (*http.Request, error) { func (c *Client) NewRequest(method string, e Endpoint, suffix string, body interface{}) (*http.Request, error) {
sshRes, err := c.sshResolver.Resolve(e, method) sshRes, err := c.SSH.Resolve(e, method)
if err != nil { if err != nil {
tracerx.Printf("ssh: %s failed, error: %s, message: %s", tracerx.Printf("ssh: %s failed, error: %s, message: %s",
e.SshUserAndHost, err.Error(), sshRes.Message, e.SshUserAndHost, err.Error(), sshRes.Message,

@ -22,6 +22,7 @@ var (
type Client struct { type Client struct {
Endpoints EndpointFinder Endpoints EndpointFinder
Credentials CredentialHelper Credentials CredentialHelper
SSH SSHResolver
Netrc NetrcFinder Netrc NetrcFinder
DialTimeout int DialTimeout int
@ -41,8 +42,6 @@ type Client struct {
hostClients map[string]*http.Client hostClients map[string]*http.Client
clientMu sync.Mutex clientMu sync.Mutex
sshResolver sshResolver
ntlmSessions map[string]ntlm.ClientSession ntlmSessions map[string]ntlm.ClientSession
ntlmMu sync.Mutex ntlmMu sync.Mutex
@ -72,11 +71,15 @@ func NewClient(osEnv Env, gitEnv Env) (*Client, error) {
httpsProxy, httpProxy, noProxy := getProxyServers(osEnv, gitEnv) httpsProxy, httpProxy, noProxy := getProxyServers(osEnv, gitEnv)
creds := &commandCredentialHelper{
SkipPrompt: !osEnv.Bool("GIT_TERMINAL_PROMPT", true),
}
sshResolver := &sshAuthClient{os: osEnv}
c := &Client{ c := &Client{
Endpoints: NewEndpointFinder(gitEnv), Endpoints: NewEndpointFinder(gitEnv),
Credentials: &commandCredentialHelper{ Credentials: creds,
SkipPrompt: !osEnv.Bool("GIT_TERMINAL_PROMPT", true), SSH: sshResolver,
},
Netrc: netrc, Netrc: netrc,
DialTimeout: gitEnv.Int("lfs.dialtimeout", 0), DialTimeout: gitEnv.Int("lfs.dialtimeout", 0),
KeepaliveTimeout: gitEnv.Int("lfs.keepalive", 0), KeepaliveTimeout: gitEnv.Int("lfs.keepalive", 0),
@ -91,7 +94,6 @@ func NewClient(osEnv Env, gitEnv Env) (*Client, error) {
NoProxy: noProxy, NoProxy: noProxy,
gitEnv: gitEnv, gitEnv: gitEnv,
osEnv: osEnv, osEnv: osEnv,
sshResolver: &sshAuthClient{os: osEnv},
} }
return c, nil return c, nil

@ -12,7 +12,7 @@ import (
"github.com/rubyist/tracerx" "github.com/rubyist/tracerx"
) )
type sshResolver interface { type SSHResolver interface {
Resolve(Endpoint, string) (sshAuthResponse, error) Resolve(Endpoint, string) (sshAuthResponse, error)
} }