Documentation
¶
Overview ¶
Package gitstore provides an abstraction on top of Go Git for use with (primarily) Kubernetes Controllers. It has basic caching capabilities and can handle multiple repositories at the same time.
The primary purpose of GitStore is to give easy access to the files in the repository at a certain git reference. To that end it checks out the code into a temporary in-memory filesystem.
Index ¶
- type AsyncRepoCloner
- type File
- type GitLog
- type Repo
- func (r *Repo) Checkout(ref string) error
- func (r *Repo) CheckoutContext(ctx context.Context, ref string) error
- func (r *Repo) Fetch() error
- func (r *Repo) FetchContext(ctx context.Context) error
- func (r *Repo) GetAllFiles(subPath string, ignoreSymlinks bool) (map[string]*File, error)
- func (r *Repo) GetFile(path string) (*File, error)
- func (r *Repo) IsDirectory(path string) (bool, error)
- func (r *Repo) IsFile(path string) (bool, error)
- func (r *Repo) LastUpdated() (time.Time, error)
- type RepoRef
- type RepoStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncRepoCloner ¶ added in v0.2.0
type AsyncRepoCloner struct { Ready bool // Ready indicates whether the clone operation has completed. RepoRef *RepoRef // RepoRef is a pointer to the RepoRef handled by this cloner. Repo *Repo // Repo contains the actual repository once clone has completed. Error error // Error is the last error encountered during the clone operation or nil. // contains filtered or unexported fields }
AsyncRepoCloner provides an asynchronous repository cloner that can perform long-running checkout operations without blocking.
func (*AsyncRepoCloner) Clone ¶ added in v0.2.0
func (rc *AsyncRepoCloner) Clone(auth transport.AuthMethod) <-chan struct{}
Clone starts an asynchronous clone of the requested repository and sets Ready to true when the repository is cloned successfully. If any errors are encountered, Ready will be false and Error will contain the error information.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a file within a git repository.
type GitLog ¶
type GitLog struct { Date time.Time // Date is the datetime of the commit this log corresponds to. Hash plumbing.Hash // Hash contains the hash of the commit. Author string // Author is the author as stored in the commit. Text string // Text is the commit message. }
GitLog contains information about a commit from the git repository log.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo represents a git repository.
func (*Repo) Checkout ¶
Checkout performs a Git checkout of the repository at the provided reference.
Note: It is assumed that the repository has already been cloned prior to Checkout() being called.
func (*Repo) CheckoutContext ¶ added in v0.6.0
CheckoutContext performs a Git checkout of the repository at the provided reference.
Note: It is assumed that the repository has already been cloned prior to Checkout() being called.
func (*Repo) Fetch ¶
Fetch performs a Git fetch of the repository.
Note: While Fetch itself is thread-safe in that it ensures a previous Fetch() is completed before starting a new one, the Repo is not. If Fetch is called from two go routines, subsequent reads may be non-deterministic.
func (*Repo) FetchContext ¶ added in v0.6.0
FetchContext performs a Git fetch of the repository.
Note: While Fetch itself is thread-safe in that it ensures a previous Fetch() is completed before starting a new one, the Repo is not. If Fetch is called from two go routines, subsequent reads may be non-deterministic.
func (*Repo) GetAllFiles ¶
GetAllFiles returns a map of Files. Each file is keyed in the map by it's path within the repository
func (*Repo) GetFile ¶
GetFile returns a pointer to a File from the repository that can be used to read its contents.
func (*Repo) IsDirectory ¶ added in v0.6.0
IsDirectory checks if the reference at a path if a directory
type RepoRef ¶
type RepoRef struct { URL string // URL where the repository is located User string // User is the username used for user/pass authentication Pass string // Pass is the password used for user/pass authentication PrivateKey []byte // PrivateKey is the ssh key material used for SSH key-based authentication // contains filtered or unexported fields }
RepoRef contains all information required to connect to a git repository