| 22 | } |
| 23 | |
| 24 | func NewClient(ctx lfshttp.Context) (*Client, error) { |
| 25 | if ctx == nil { |
| 26 | ctx = lfshttp.NewContext(nil, nil, nil) |
| 27 | } |
| 28 | |
| 29 | gitEnv := ctx.GitEnv() |
| 30 | osEnv := ctx.OSEnv() |
| 31 | |
| 32 | httpClient, err := lfshttp.NewClient(ctx) |
| 33 | if err != nil { |
| 34 | return nil, errors.Wrap(err, tr.Tr.Get("error creating HTTP client")) |
| 35 | } |
| 36 | |
| 37 | c := &Client{ |
| 38 | Endpoints: NewEndpointFinder(ctx), |
| 39 | client: httpClient, |
| 40 | context: ctx, |
| 41 | credContext: creds.NewCredentialHelperContext(gitEnv, osEnv), |
| 42 | access: creds.AllAccessModes(), |
| 43 | } |
| 44 | |
| 45 | return c, nil |
| 46 | } |
| 47 | |
| 48 | func (c *Client) Context() lfshttp.Context { |
| 49 | return c.context |