Documentation
¶
Overview ¶
Package config collects together all configuration settings NOTE: Subject to change, do not rely on this package from outside git-lfs source
Index ¶
- Constants
- Variables
- func ResolveGitBasicDirs()
- type Configuration
- func (c *Configuration) Access(operation string) string
- func (c *Configuration) AllGitConfig() map[string]string
- func (c *Configuration) BasicTransfersOnly() bool
- func (c *Configuration) BatchTransfer() bool
- func (c *Configuration) ConcurrentTransfers() int
- func (c *Configuration) Endpoint(operation string) Endpoint
- func (c *Configuration) EndpointAccess(e Endpoint) string
- func (c *Configuration) Extensions() map[string]Extension
- func (c *Configuration) FetchExcludePaths() []string
- func (c *Configuration) FetchIncludePaths() []string
- func (c *Configuration) FetchPruneConfig() FetchPruneConfig
- func (c *Configuration) FindNetrcHost(host string) (*netrc.Machine, error)
- func (c *Configuration) GitProtocol() string
- func (c *Configuration) GitRemoteUrl(remote string, forpush bool) string
- func (c *Configuration) NtlmAccess(operation string) bool
- func (c *Configuration) PrivateAccess(operation string) bool
- func (c *Configuration) RemoteEndpoint(remote, operation string) Endpoint
- func (c *Configuration) Remotes() []string
- func (c *Configuration) ReplaceUrlAlias(rawurl string) string
- func (c *Configuration) SetAccess(operation string, authType string)
- func (c *Configuration) SetEndpointAccess(e Endpoint, authType string)
- func (c *Configuration) SetManualEndpoint(e Endpoint)
- func (c *Configuration) SetNetrc(n netrcfinder)
- func (c *Configuration) SkipDownloadErrors() bool
- func (c *Configuration) SortedExtensions() ([]Extension, error)
- func (c *Configuration) TusTransfersAllowed() bool
- func (c *Configuration) Unmarshal(v interface{}) error
- type Endpoint
- type Environment
- type Extension
- type FetchPruneConfig
- type Fetcher
- type GitConfig
- type GitFetcher
- type OsFetcher
- type Values
Constants ¶
const EndpointUrlUnknown = "<unknown>"
Variables ¶
var ( Config = New() ShowConfigWarnings = false )
var ( LocalWorkingDir string LocalGitDir string // parent of index / config / hooks etc LocalGitStorageDir string // parent of objects/lfs (may be same as LocalGitDir but may not) LocalReferenceDir string // alternative local media dir (relative to clone reference repo) LocalLogDir string )
var ( GitCommit string Version = "1.4.3" VersionDesc string )
Functions ¶
func ResolveGitBasicDirs ¶
func ResolveGitBasicDirs()
Determins the LocalWorkingDir, LocalGitDir etc
Types ¶
type Configuration ¶
type Configuration struct { // Os provides a `*Environment` used to access to the system's // environment through os.Getenv. It is the point of entry for all // system environment configuration. Os Environment // Git provides a `*Environment` used to access to the various levels of // `.gitconfig`'s. It is the point of entry for all Git environment // configuration. Git Environment CurrentRemote string NtlmSession ntlm.ClientSession IsTracingHttp bool IsDebuggingHttp bool IsLoggingStats bool // contains filtered or unexported fields }
func New ¶ added in v1.3.1
func New() *Configuration
func NewFrom ¶ added in v1.4.0
func NewFrom(v Values) *Configuration
NewFrom returns a new `*config.Configuration` that reads both its Git and Enviornment-level values from the ones provided instead of the actual `.gitconfig` file or `os.Getenv`, respectively.
This method should only be used during testing.
func (*Configuration) Access ¶
func (c *Configuration) Access(operation string) string
Access returns the access auth type.
func (*Configuration) AllGitConfig ¶
func (c *Configuration) AllGitConfig() map[string]string
func (*Configuration) BasicTransfersOnly ¶
func (c *Configuration) BasicTransfersOnly() bool
BasicTransfersOnly returns whether to only allow "basic" HTTP transfers. Default is false, including if the lfs.basictransfersonly is invalid
func (*Configuration) BatchTransfer ¶
func (c *Configuration) BatchTransfer() bool
func (*Configuration) ConcurrentTransfers ¶
func (c *Configuration) ConcurrentTransfers() int
func (*Configuration) Endpoint ¶
func (c *Configuration) Endpoint(operation string) Endpoint
func (*Configuration) EndpointAccess ¶
func (c *Configuration) EndpointAccess(e Endpoint) string
func (*Configuration) Extensions ¶
func (c *Configuration) Extensions() map[string]Extension
func (*Configuration) FetchExcludePaths ¶
func (c *Configuration) FetchExcludePaths() []string
func (*Configuration) FetchIncludePaths ¶
func (c *Configuration) FetchIncludePaths() []string
func (*Configuration) FetchPruneConfig ¶
func (c *Configuration) FetchPruneConfig() FetchPruneConfig
func (*Configuration) FindNetrcHost ¶
func (c *Configuration) FindNetrcHost(host string) (*netrc.Machine, error)
func (*Configuration) GitProtocol ¶
func (c *Configuration) GitProtocol() string
GitProtocol returns the protocol for the LFS API when converting from a git:// remote url.
func (*Configuration) GitRemoteUrl ¶
func (c *Configuration) GitRemoteUrl(remote string, forpush bool) string
GitRemoteUrl returns the git clone/push url for a given remote (blank if not found) the forpush argument is to cater for separate remote.name.pushurl settings
func (*Configuration) NtlmAccess ¶
func (c *Configuration) NtlmAccess(operation string) bool
func (*Configuration) PrivateAccess ¶
func (c *Configuration) PrivateAccess(operation string) bool
PrivateAccess will retrieve the access value and return true if the value is set to private. When a repo is marked as having private access, the http requests for the batch api will fetch the credentials before running, otherwise the request will run without credentials.
func (*Configuration) RemoteEndpoint ¶
func (c *Configuration) RemoteEndpoint(remote, operation string) Endpoint
func (*Configuration) Remotes ¶
func (c *Configuration) Remotes() []string
func (*Configuration) ReplaceUrlAlias ¶ added in v1.4.0
func (c *Configuration) ReplaceUrlAlias(rawurl string) string
ReplaceUrlAlias returns a url with a prefix from a `url.*.insteadof` git config setting. If multiple aliases match, use the longest one. See https://git-scm.com/docs/git-config for Git's docs.
func (*Configuration) SetAccess ¶
func (c *Configuration) SetAccess(operation string, authType string)
SetAccess will set the private access flag in .git/config.
func (*Configuration) SetEndpointAccess ¶
func (c *Configuration) SetEndpointAccess(e Endpoint, authType string)
func (*Configuration) SetManualEndpoint ¶
func (c *Configuration) SetManualEndpoint(e Endpoint)
Manually set an Endpoint to use instead of deriving from Git config
func (*Configuration) SetNetrc ¶
func (c *Configuration) SetNetrc(n netrcfinder)
Manually override the netrc config
func (*Configuration) SkipDownloadErrors ¶
func (c *Configuration) SkipDownloadErrors() bool
func (*Configuration) SortedExtensions ¶
func (c *Configuration) SortedExtensions() ([]Extension, error)
SortedExtensions gets the list of extensions ordered by Priority
func (*Configuration) TusTransfersAllowed ¶
func (c *Configuration) TusTransfersAllowed() bool
TusTransfersAllowed returns whether to only use "tus.io" HTTP transfers. Default is false, including if the lfs.tustransfers is invalid
func (*Configuration) Unmarshal ¶ added in v1.4.0
func (c *Configuration) Unmarshal(v interface{}) error
Unmarshal unmarshals the *Configuration in context into all of `v`'s fields, according to the following rules:
Values are marshaled according to the given key and environment, as follows:
type T struct { Field string `git:"key"` Other string `os:"key"` }
If an unknown environment is given, an error will be returned. If there is no method supporting conversion into a field's type, an error will be returned. If no value is associated with the given key and environment, the field will // only be modified if there is a config value present matching the given key. If the field is already set to a non-zero value of that field's type, then it will be left alone.
Otherwise, the field will be set to the value of calling the appropriately-typed method on the specified environment.
type Endpoint ¶
An Endpoint describes how to access a Git LFS server.
func NewEndpoint ¶
NewEndpoint initializes a new Endpoint for a given URL.
func NewEndpointFromCloneURL ¶
NewEndpointFromCloneURL creates an Endpoint from a git clone URL by appending "[.git]/info/lfs".
func NewEndpointFromCloneURLWithConfig ¶
func NewEndpointFromCloneURLWithConfig(url string, c *Configuration) Endpoint
NewEndpointFromCloneURLWithConfig creates an Endpoint from a git clone URL by appending "[.git]/info/lfs".
func NewEndpointWithConfig ¶
func NewEndpointWithConfig(rawurl string, c *Configuration) Endpoint
NewEndpointWithConfig initializes a new Endpoint for a given URL.
type Environment ¶ added in v1.4.0
type Environment interface { // Get is shorthand for calling `e.Fetcher.Get(key)`. Get(key string) (val string, ok bool) // Bool returns the boolean state associated with a given key, or the // value "def", if no value was associated. // // The "boolean state associated with a given key" is defined as the // case-insensitive string comparison with the following: // // 1) true if... // "true", "1", "on", "yes", or "t" // 2) false if... // "false", "0", "off", "no", "f", or otherwise. Bool(key string, def bool) (val bool) // Int returns the int value associated with a given key, or the value // "def", if no value was associated. // // To convert from a the string value attached to a given key, // `strconv.Atoi(val)` is called. If `Atoi` returned a non-nil error, // then the value "def" will be returned instead. // // Otherwise, if the value was converted `string -> int` successfully, // then it will be returned wholesale. Int(key string, def int) (val int) }
An Environment adds additional behavior to a Fetcher, such a type conversion, and default values.
`Environment`s are the primary way to communicate with various configuration sources, such as the OS environment variables, the `.gitconfig`, and even `map[string]string`s.
func EnvironmentOf ¶ added in v1.4.0
func EnvironmentOf(f Fetcher) Environment
EnvironmentOf creates a new `Environment` initialized with the givne `Fetcher`, "f".
type Extension ¶
An Extension describes how to manipulate files during smudge and clean. Extensions are parsed from the Git config.
type FetchPruneConfig ¶
type FetchPruneConfig struct { // The number of days prior to current date for which (local) refs other than HEAD // will be fetched with --recent (default 7, 0 = only fetch HEAD) FetchRecentRefsDays int `git:"lfs.fetchrecentrefsdays"` // Makes the FetchRecentRefsDays option apply to remote refs from fetch source as well (default true) FetchRecentRefsIncludeRemotes bool `git:"lfs.fetchrecentremoterefs"` // number of days prior to latest commit on a ref that we'll fetch previous // LFS changes too (default 0 = only fetch at ref) FetchRecentCommitsDays int `git:"lfs.fetchrecentcommitsdays"` // Whether to always fetch recent even without --recent FetchRecentAlways bool `git:"lfs.fetchrecentalways"` // Number of days added to FetchRecent*; data outside combined window will be // deleted when prune is run. (default 3) PruneOffsetDays int `git:"lfs.pruneoffsetdays"` // Always verify with remote before pruning PruneVerifyRemoteAlways bool `git:"lfs.pruneverifyremotealways"` // Name of remote to check for unpushed and verify checks PruneRemoteName string `git:"lfs.pruneremotetocheck"` }
FetchPruneConfig collects together the config options that control fetching and pruning
type Fetcher ¶ added in v1.4.0
type Fetcher interface { // Get returns the string value associated with a given key and a bool // determining if the key exists. Get(key string) (val string, ok bool) }
Fetcher provides an interface to get typed information out of a configuration "source". These sources could be the OS enviornment, a .gitconfig, or even just a `map`.
func MapFetcher ¶ added in v1.4.0
type GitConfig ¶ added in v1.4.0
func NewGitConfig ¶ added in v1.4.0
type GitFetcher ¶ added in v1.4.0
type GitFetcher struct {
// contains filtered or unexported fields
}
func ReadGitConfig ¶ added in v1.4.0
func (*GitFetcher) Get ¶ added in v1.4.0
func (g *GitFetcher) Get(key string) (val string, ok bool)
Get implements the Fetcher interface, and returns the value associated with a given key and true, signaling that the value was present. Otherwise, an empty string and false will be returned, signaling that the value was absent.
Map lookup by key is case-insensitive, as per the .gitconfig specification.
Get is safe to call across multiple goroutines.
type OsFetcher ¶ added in v1.4.0
type OsFetcher struct {
// contains filtered or unexported fields
}
OsFetcher is an implementation of the Fetcher type for communicating with the system's environment.
It is safe to use across multiple goroutines.
func NewOsFetcher ¶ added in v1.4.0
func NewOsFetcher() *OsFetcher
NewOsFetcher returns a new *OsFetcher.
func (*OsFetcher) Get ¶ added in v1.4.0
Get returns the value associated with the given key as stored in the local cache, or in the operating system's environment variables.
If there was a cache-hit, the value will be returned from the cache, skipping a check against os.Getenv. Otherwise, the value will be fetched from the system, stored in the cache, and then returned. If no value was present in the cache or in the system, an empty string will be returned.
Get is safe to call across multiple goroutines.
type Values ¶ added in v1.4.0
type Values struct {
// Git and Os are the stand-in maps used to provide values for their
// respective environments.
Git, Os map[string]string
}
Values is a convenience type used to call the NewFromValues function. It specifies `Git` and `Env` maps to use as mock values, instead of calling out to real `.gitconfig`s and the `os.Getenv` function.