git-lfs/lfsapi/lfsapi.go

41 lines
774 B
Go
Raw Normal View History

package lfsapi
2016-12-16 22:43:05 +00:00
import (
2016-12-22 22:31:48 +00:00
"fmt"
2016-12-16 22:43:05 +00:00
"github.com/git-lfs/git-lfs/creds"
2016-12-16 22:47:02 +00:00
"github.com/git-lfs/git-lfs/errors"
"github.com/git-lfs/git-lfs/lfshttp"
2016-12-16 22:43:05 +00:00
)
type Client struct {
2016-12-19 21:38:06 +00:00
Endpoints EndpointFinder
Credentials creds.CredentialHelper
2016-12-20 17:02:25 +00:00
credContext *creds.CredentialHelperContext
client *lfshttp.Client
}
func NewClient(ctx lfshttp.Context) (*Client, error) {
if ctx == nil {
ctx = lfshttp.NewContext(nil, nil, nil)
2016-12-20 17:29:26 +00:00
}
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
}