lfsapi

package
v2.4.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2018 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const MediaType = "application/vnd.git-lfs+json; charset=utf-8"
View Source
const UrlUnknown = "<unknown>"

Variables

View Source
var (
	UserAgent = "git-lfs"
)

Functions

func DecodeJSON

func DecodeJSON(res *http.Response, obj interface{}) error

func IsDecodeTypeError

func IsDecodeTypeError(err error) bool

func IsHTTP

func IsHTTP(err error) (*http.Response, bool)

func MarshalToRequest

func MarshalToRequest(req *http.Request, obj interface{}) error

func NewStatusCodeError

func NewStatusCodeError(res *http.Response) error

func Retries

func Retries(req *http.Request) (int, bool)

Retries returns the number of retries requested for a given http.Request.

func TestNtlmClientSession

func TestNtlmClientSession(t *testing.T)

func TestNtlmClientSessionBadCreds

func TestNtlmClientSessionBadCreds(t *testing.T)

func WithRetries

func WithRetries(req *http.Request, n int) *http.Request

WithRetries stores the desired number of retries "n" on the given http.Request, and causes it to be retried "n" times in the case of a non-nil network related error.

Types

type Access

type Access string
const (
	NoneAccess      Access = "none"
	BasicAccess     Access = "basic"
	PrivateAccess   Access = "private"
	NegotiateAccess Access = "negotiate"
	NTLMAccess      Access = "ntlm"
)

type AskPassCredentialHelper

type AskPassCredentialHelper struct {
	// Program is the executable program's absolute or relative name.
	Program string
}

AskPassCredentialHelper implements the CredentialHelper type for GIT_ASKPASS and 'core.askpass' configuration values.

func (*AskPassCredentialHelper) Approve

func (a *AskPassCredentialHelper) Approve(_ Creds) error

Approve implements CredentialHelper.Approve, and returns nil. The ASKPASS credential helper does not implement credential approval.

func (*AskPassCredentialHelper) Fill

func (a *AskPassCredentialHelper) Fill(what Creds) (Creds, error)

Fill implements fill by running the ASKPASS program and returning its output as a password encoded in the Creds type given the key "password".

It accepts the password as coming from the program's stdout, as when invoked with the given arguments (see (*AskPassCredentialHelper).args() below)./

If there was an error running the command, it is returned instead of a set of filled credentials.

func (*AskPassCredentialHelper) Reject

func (a *AskPassCredentialHelper) Reject(_ Creds) error

Reject implements CredentialHelper.Reject, and returns nil. The ASKPASS credential helper does not implement credential rejection.

type Client

type Client struct {
	Endpoints   EndpointFinder
	Credentials CredentialHelper
	SSH         SSHResolver
	Netrc       NetrcFinder

	DialTimeout         int
	KeepaliveTimeout    int
	TLSTimeout          int
	ConcurrentTransfers int
	SkipSSLVerify       bool

	Verbose          bool
	DebuggingVerbose bool
	VerboseOut       io.Writer

	LoggingStats bool // DEPRECATED
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx Context) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

Close closes any resources that this client opened.

func (*Client) CurrentUser

func (c *Client) CurrentUser() (string, string)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do sends an HTTP request to get an HTTP response. It wraps net/http, adding extra headers, redirection handling, and error reporting.

func (*Client) DoWithAuth

func (c *Client) DoWithAuth(remote string, req *http.Request) (*http.Response, error)

DoWithAuth sends an HTTP request to get an HTTP response. It attempts to add authentication from netrc or git's credential helpers if necessary, supporting basic and ntlm authentication.

func (*Client) GitEnv

func (c *Client) GitEnv() config.Environment

func (*Client) LogHTTPStats

func (c *Client) LogHTTPStats(w io.WriteCloser)

func (*Client) LogRequest

func (c *Client) LogRequest(r *http.Request, reqKey string) *http.Request

LogRequest tells the client to log the request's stats to the http log after the response body has been read.

func (*Client) LogResponse

func (c *Client) LogResponse(key string, res *http.Response)

LogResponse sends the current response stats to the http log.

DEPRECATED: Use LogRequest() instead.

func (*Client) LogStats

func (c *Client) LogStats(out io.Writer)

LogStats is intended to be called after all HTTP operations for the commmand have finished. It dumps k/v logs, one line per httpTransfer into a log file with the current timestamp.

DEPRECATED: Call LogHTTPStats() before the first HTTP request.

func (*Client) NewRequest

func (c *Client) NewRequest(method string, e Endpoint, suffix string, body interface{}) (*http.Request, error)

func (*Client) OSEnv

func (c *Client) OSEnv() config.Environment

type ClientError

type ClientError struct {
	Message          string `json:"message"`
	DocumentationUrl string `json:"documentation_url,omitempty"`
	RequestId        string `json:"request_id,omitempty"`
	// contains filtered or unexported fields
}

func (*ClientError) Error

func (e *ClientError) Error() string

func (*ClientError) HTTPResponse

func (e *ClientError) HTTPResponse() *http.Response

type Context

type Context interface {
	GitConfig() *git.Configuration
	OSEnv() config.Environment
	GitEnv() config.Environment
}

func NewContext

func NewContext(gitConf *git.Configuration, osEnv, gitEnv map[string]string) Context

type CredentialHelper

type CredentialHelper interface {
	Fill(Creds) (Creds, error)
	Reject(Creds) error
	Approve(Creds) error
}

CredentialHelper is an interface used by the lfsapi Client to interact with the 'git credential' command: https://git-scm.com/docs/gitcredentials Other implementations include ASKPASS support, and an in-memory cache.

func NewCredentialHelpers

func NewCredentialHelpers(helpers []CredentialHelper) CredentialHelper

NewCredentialHelpers initializes a new CredentialHelpers from the given slice of CredentialHelper instances.

type CredentialHelpers

type CredentialHelpers struct {
	// contains filtered or unexported fields
}

CredentialHelpers iterates through a slice of CredentialHelper objects CredentialHelpers is a []CredentialHelper that iterates through each credential helper to fill, reject, or approve credentials. Typically, the first success returns immediately. Errors are reported to tracerx, unless all credential helpers return errors. Any erroring credential helpers are skipped for future calls.

A CredentialHelper can return a credHelperNoOp error, signaling that the CredentialHelpers should try the next one.

func (*CredentialHelpers) Approve

func (s *CredentialHelpers) Approve(what Creds) error

Approve implements CredentialHelper.Approve and approves the given Creds "what" with the first successful CredentialHelper. If an error occurrs, it calls Reject() with the same Creds and returns the error immediately. This ensures a caching credential helper removes the cache, since the Erroring CredentialHelper never successfully saved it.

func (*CredentialHelpers) Fill

func (s *CredentialHelpers) Fill(what Creds) (Creds, error)

Fill implements CredentialHelper.Fill by asking each CredentialHelper in order to fill the credentials.

If a fill was successful, it is returned immediately, and no other `CredentialHelper`s are consulted. If any CredentialHelper returns an error, it is reported to tracerx, and the next one is attempted. If they all error, then a collection of all the error messages is returned. Erroring credential helpers are added to the skip list, and never attempted again for the lifetime of the current Git LFS command.

func (*CredentialHelpers) Reject

func (s *CredentialHelpers) Reject(what Creds) error

Reject implements CredentialHelper.Reject and rejects the given Creds "what" with the first successful attempt.

type Creds

type Creds map[string]string

Creds represents a set of key/value pairs that are passed to 'git credential' as input.

type Endpoint

type Endpoint struct {
	Url            string
	SshUserAndHost string
	SshPath        string
	SshPort        string
	Operation      string
}

An Endpoint describes how to access a Git LFS server.

type EndpointFinder

type EndpointFinder interface {
	NewEndpointFromCloneURL(rawurl string) Endpoint
	NewEndpoint(rawurl string) Endpoint
	Endpoint(operation, remote string) Endpoint
	RemoteEndpoint(operation, remote string) Endpoint
	GitRemoteURL(remote string, forpush bool) string
	AccessFor(rawurl string) Access
	SetAccess(rawurl string, access Access)
	GitProtocol() string
}

func NewEndpointFinder

func NewEndpointFinder(ctx Context) EndpointFinder

type NetrcFinder

type NetrcFinder interface {
	FindMachine(string) *netrc.Machine
}

func ParseNetrc

func ParseNetrc(osEnv config.Environment) (NetrcFinder, string, error)

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Seeker
	io.ReadCloser
}

func NewByteBody

func NewByteBody(by []byte) ReadSeekCloser

type SSHResolver

type SSHResolver interface {
	Resolve(Endpoint, string) (sshAuthResponse, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL