| 67 | } |
| 68 | |
| 69 | func NewClient(ctx Context) (*Client, error) { |
| 70 | if ctx == nil { |
| 71 | ctx = NewContext(nil, nil, nil) |
| 72 | } |
| 73 | |
| 74 | gitEnv := ctx.GitEnv() |
| 75 | osEnv := ctx.OSEnv() |
| 76 | |
| 77 | cacheCreds := gitEnv.Bool("lfs.cachecredentials", true) |
| 78 | var sshResolver SSHResolver = &sshAuthClient{os: osEnv, git: gitEnv} |
| 79 | if cacheCreds { |
| 80 | sshResolver = withSSHCache(sshResolver) |
| 81 | } |
| 82 | |
| 83 | c := &Client{ |
| 84 | SSH: sshResolver, |
| 85 | DialTimeout: gitEnv.Int("lfs.dialtimeout", 0), |
| 86 | KeepaliveTimeout: gitEnv.Int("lfs.keepalive", 0), |
| 87 | TLSTimeout: gitEnv.Int("lfs.tlstimeout", 0), |
| 88 | ConcurrentTransfers: gitEnv.Int("lfs.concurrenttransfers", 8), |
| 89 | SkipSSLVerify: !gitEnv.Bool("http.sslverify", true) || osEnv.Bool("GIT_SSL_NO_VERIFY", false), |
| 90 | Verbose: osEnv.Bool("GIT_CURL_VERBOSE", false), |
| 91 | DebuggingVerbose: osEnv.Bool("LFS_DEBUG_HTTP", false), |
| 92 | gitEnv: gitEnv, |
| 93 | osEnv: osEnv, |
| 94 | uc: config.NewURLConfig(gitEnv), |
| 95 | sshTries: gitEnv.Int("lfs.ssh.retries", 5), |
| 96 | credHelperContext: creds.NewCredentialHelperContext(gitEnv, osEnv), |
| 97 | } |
| 98 | |
| 99 | return c, nil |
| 100 | } |
| 101 | |
| 102 | func (c *Client) GitEnv() config.Environment { |
| 103 | return c.gitEnv |