git-lfs/lfsapi/lfsapi.go
brian m. carlson fe2fa6746b
Use git-lfs version of go-ntlm
The upstream of go-ntlm has archived its repository and is no longer
doing releases. Because this dependency is required for Git LFS, we've
created our own fork to ensure that the upstream repo doesn't disappear
on us. Use our own copy of go-ntlm within Git LFS.
2019-04-01 19:00:38 +00:00

46 lines
887 B
Go

package lfsapi
import (
"fmt"
"sync"
"github.com/git-lfs/git-lfs/creds"
"github.com/git-lfs/git-lfs/errors"
"github.com/git-lfs/git-lfs/lfshttp"
"github.com/git-lfs/go-ntlm/ntlm"
)
type Client struct {
Endpoints EndpointFinder
Credentials creds.CredentialHelper
ntlmSessions map[string]ntlm.ClientSession
ntlmMu sync.Mutex
credContext *creds.CredentialHelperContext
client *lfshttp.Client
}
func NewClient(ctx lfshttp.Context) (*Client, error) {
if ctx == nil {
ctx = lfshttp.NewContext(nil, nil, nil)
}
gitEnv := ctx.GitEnv()
osEnv := ctx.OSEnv()
httpClient, err := lfshttp.NewClient(ctx)
if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("error creating http client"))
}
c := &Client{
Endpoints: NewEndpointFinder(ctx),
client: httpClient,
credContext: creds.NewCredentialHelperContext(gitEnv, osEnv),
}
return c, nil
}