From 34e8c01baa831a5eb9e9bce180dff02cff736a5d Mon Sep 17 00:00:00 2001 From: risk danger olson Date: Thu, 23 Mar 2017 13:48:52 -0600 Subject: [PATCH] lfsapi: export SSHResolver and property --- lfsapi/client.go | 2 +- lfsapi/lfsapi.go | 16 +++++++++------- lfsapi/ssh.go | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lfsapi/client.go b/lfsapi/client.go index da220186..ed718350 100644 --- a/lfsapi/client.go +++ b/lfsapi/client.go @@ -18,7 +18,7 @@ var UserAgent = "git-lfs" 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) { - sshRes, err := c.sshResolver.Resolve(e, method) + sshRes, err := c.SSH.Resolve(e, method) if err != nil { tracerx.Printf("ssh: %s failed, error: %s, message: %s", e.SshUserAndHost, err.Error(), sshRes.Message, diff --git a/lfsapi/lfsapi.go b/lfsapi/lfsapi.go index e5f37923..bf33f858 100644 --- a/lfsapi/lfsapi.go +++ b/lfsapi/lfsapi.go @@ -22,6 +22,7 @@ var ( type Client struct { Endpoints EndpointFinder Credentials CredentialHelper + SSH SSHResolver Netrc NetrcFinder DialTimeout int @@ -41,8 +42,6 @@ type Client struct { hostClients map[string]*http.Client clientMu sync.Mutex - sshResolver sshResolver - ntlmSessions map[string]ntlm.ClientSession ntlmMu sync.Mutex @@ -72,11 +71,15 @@ func NewClient(osEnv Env, gitEnv Env) (*Client, error) { httpsProxy, httpProxy, noProxy := getProxyServers(osEnv, gitEnv) + creds := &commandCredentialHelper{ + SkipPrompt: !osEnv.Bool("GIT_TERMINAL_PROMPT", true), + } + sshResolver := &sshAuthClient{os: osEnv} + c := &Client{ - Endpoints: NewEndpointFinder(gitEnv), - Credentials: &commandCredentialHelper{ - SkipPrompt: !osEnv.Bool("GIT_TERMINAL_PROMPT", true), - }, + Endpoints: NewEndpointFinder(gitEnv), + Credentials: creds, + SSH: sshResolver, Netrc: netrc, DialTimeout: gitEnv.Int("lfs.dialtimeout", 0), KeepaliveTimeout: gitEnv.Int("lfs.keepalive", 0), @@ -91,7 +94,6 @@ func NewClient(osEnv Env, gitEnv Env) (*Client, error) { NoProxy: noProxy, gitEnv: gitEnv, osEnv: osEnv, - sshResolver: &sshAuthClient{os: osEnv}, } return c, nil diff --git a/lfsapi/ssh.go b/lfsapi/ssh.go index 185692ee..c055cd47 100644 --- a/lfsapi/ssh.go +++ b/lfsapi/ssh.go @@ -12,7 +12,7 @@ import ( "github.com/rubyist/tracerx" ) -type sshResolver interface { +type SSHResolver interface { Resolve(Endpoint, string) (sshAuthResponse, error) }