flux: github.com/fluxcd/flux/pkg/git Index | Files | Directories

package git

import "github.com/fluxcd/flux/pkg/git"


Package Files

errors.go export.go mirrors.go operations.go repo.go signature.go url.go working.go


const (
    CheckPushTagPrefix = "flux-write-check"


var (
    ErrNoChanges  = errors.New("no changes made in repo")
    ErrNoConfig   = errors.New("git repo does not have valid config")
    ErrNotCloned  = errors.New("git repo has not been cloned yet")
    ErrClonedOnly = errors.New("git repo has been cloned but not yet checked for write access")
var (
    ErrReadOnly = errors.New("cannot make a working clone of a read-only git repo")
var NoRepoError = &fluxerr.Error{
    Type: fluxerr.User,
    Err:  errors.New("no repo in user config"),
    Help: "" /* 245 byte string literal not displayed */,

func CloningError Uses

func CloningError(url string, actual error) error

func ErrUpstreamNotWritable Uses

func ErrUpstreamNotWritable(url string, actual error) error

func MakeAbsolutePaths Uses

func MakeAbsolutePaths(r interface{ Dir() string }, relativePaths []string) []string

MakeAbsolutePaths returns the absolute path for each of the relativePaths given, taking the repo's location as the base.

func PushError Uses

func PushError(url string, actual error) error

type Branch Uses

type Branch string

type Checkout Uses

type Checkout struct {
    // contains filtered or unexported fields

Checkout is a local working clone of the remote repo. It is intended to be used for one-off "transactions", e.g,. committing changes then pushing upstream. It has no locking.

func (*Checkout) AbsolutePaths Uses

func (c *Checkout) AbsolutePaths() []string

AbsolutePaths returns the absolute paths as configured. It ensures that at least one path is returned, so that it can be used with `Manifest.LoadManifests`.

func (*Checkout) Add Uses

func (c *Checkout) Add(ctx context.Context, path string) error

func (*Checkout) Checkout Uses

func (c *Checkout) Checkout(ctx context.Context, rev string) error

func (*Checkout) CommitAndPush Uses

func (c *Checkout) CommitAndPush(ctx context.Context, commitAction CommitAction, note interface{}, addUntracked bool) error

CommitAndPush commits changes made in this checkout, along with any extra data as a note, and pushes the commit and note to the remote repo.

func (*Checkout) HeadRevision Uses

func (c *Checkout) HeadRevision(ctx context.Context) (string, error)

func (*Checkout) MoveTagAndPush Uses

func (c *Checkout) MoveTagAndPush(ctx context.Context, tagAction TagAction) error

type Commit Uses

type Commit struct {
    Signature Signature
    Revision  string
    Message   string

type CommitAction Uses

type CommitAction struct {
    Author     string
    Message    string
    SigningKey string

CommitAction is a struct holding commit information

type Config Uses

type Config struct {
    Branch      string   // branch we're syncing to
    Paths       []string // paths within the repo containing files we care about
    NotesRef    string
    UserName    string
    UserEmail   string
    SigningKey  string
    SetAuthor   bool
    SkipMessage string

Config holds some values we use when working in the working clone of a repo.

type Export Uses

type Export struct {
    // contains filtered or unexported fields

func (*Export) ChangedFiles Uses

func (e *Export) ChangedFiles(ctx context.Context, sinceRef string, paths []string) ([]string, error)

ChangedFiles does a git diff listing changed files

func (*Export) Clean Uses

func (e *Export) Clean() error

func (*Export) Dir Uses

func (e *Export) Dir() string

func (*Export) SecretUnseal Uses

func (e *Export) SecretUnseal(ctx context.Context) error

SecretUnseal unseals git secrets in the clone.

type GitRepoStatus Uses

type GitRepoStatus string

GitRepoStatus represents the progress made synchronising with a git repo. These are given below in expected order, but the status may go backwards if e.g., a deploy key is deleted.

const (
    RepoNoConfig    GitRepoStatus = "unconfigured" // configuration is empty
    RepoNew         GitRepoStatus = "new"          // no attempt made to clone it yet
    RepoCloned      GitRepoStatus = "cloned"       // has been read (cloned); no attempt made to write
    RepoReady       GitRepoStatus = "ready"        // has been written to, so ready to sync
    RepoUnreachable GitRepoStatus = "unreachable"  // git repo is unreachable due to incorrect URL or DNS resolve failure

type IsReadOnly Uses

type IsReadOnly bool
var ReadOnly IsReadOnly = true

type Mirrors Uses

type Mirrors struct {
    // contains filtered or unexported fields

Maintains several git mirrors as a set, with a mechanism for signalling when some have had changes.

The advantage of it being a set is that you can add to it idempotently; if you need a repo to be mirrored, add it, and it will either already be mirrored, or that will be started.

func NewMirrors Uses

func NewMirrors() *Mirrors

func (*Mirrors) Changes Uses

func (m *Mirrors) Changes() <-chan map[string]struct{}

Changes gets a channel upon which notifications of which repos have changed will be sent.

func (*Mirrors) Get Uses

func (m *Mirrors) Get(name string) (*Repo, bool)

Get returns the named repo or nil, and a bool indicating whether the repo is being mirrored.

func (*Mirrors) Mirror Uses

func (m *Mirrors) Mirror(name string, remote Remote, options ...Option) bool

Mirror instructs the Mirrors to track a particular repo; if there is already a repo with the name given, nothing is done. Otherwise, the repo given will be mirrored, and changes signalled on the channel obtained with `Changes()`. The return value indicates whether the repo was already present (`true` if so, `false` otherwise).

func (*Mirrors) RefreshAll Uses

func (m *Mirrors) RefreshAll(timeout time.Duration) []error

RefreshAll instructs all the repos to refresh, this means fetching updated refs, and associated objects. The given timeout is the timeout per mirror and _not_ the timeout for the whole operation. It returns a collection of eventual errors it encountered.

func (*Mirrors) StopAllAndWait Uses

func (m *Mirrors) StopAllAndWait()

StopAllAndWait stops all the repos refreshing, and waits for them to indicate they've done so.

func (*Mirrors) StopOne Uses

func (m *Mirrors) StopOne(name string)

StopOne stops the repo given by `remote`, and cleans up after it (i.e., removes filesystem traces), if it is being tracked.

type NotReadyError Uses

type NotReadyError struct {
    // contains filtered or unexported fields

func (NotReadyError) Error Uses

func (err NotReadyError) Error() string

func (NotReadyError) Unwrap Uses

func (err NotReadyError) Unwrap() error

type Option Uses

type Option interface {
    // contains filtered or unexported methods

type PollInterval Uses

type PollInterval time.Duration

type Remote Uses

type Remote struct {
    // URL is where we clone from
    URL string `json:"url"`

Remote points at a git repo somewhere.

func (Remote) Equivalent Uses

func (r Remote) Equivalent(u string) bool

Equivalent compares the given URL with the remote URL without taking protocols or `.git` suffixes into account.

func (Remote) SafeURL Uses

func (r Remote) SafeURL() string

type Repo Uses

type Repo struct {
    C chan struct{}
    // contains filtered or unexported fields

func NewRepo Uses

func NewRepo(origin Remote, opts ...Option) *Repo

NewRepo constructs a repo mirror which will sync itself.

func (*Repo) BranchHead Uses

func (r *Repo) BranchHead(ctx context.Context) (string, error)

BranchHead returns the HEAD revision (SHA1) of the configured branch

func (*Repo) Clean Uses

func (r *Repo) Clean()

Clean removes the mirrored repo. Syncing may continue with a new directory, so you may need to stop that first.

func (*Repo) Clone Uses

func (r *Repo) Clone(ctx context.Context, conf Config) (*Checkout, error)

Clone returns a local working clone of the sync'ed `*Repo`, using the config given.

func (*Repo) CommitsBefore Uses

func (r *Repo) CommitsBefore(ctx context.Context, ref string, firstParent bool, paths ...string) ([]Commit, error)

func (*Repo) CommitsBetween Uses

func (r *Repo) CommitsBetween(ctx context.Context, ref1, ref2 string, firstParent bool, paths ...string) ([]Commit, error)

func (*Repo) DeleteTag Uses

func (r *Repo) DeleteTag(ctx context.Context, tag string) error

func (*Repo) Dir Uses

func (r *Repo) Dir() string

Dir returns the local directory into which the repo has been cloned, if it has been cloned.

func (*Repo) Export Uses

func (r *Repo) Export(ctx context.Context, ref string) (*Export, error)

Export creates a minimal clone of the repo, at the ref given.

func (*Repo) GetNote Uses

func (r *Repo) GetNote(ctx context.Context, rev, notesRef string, note interface{}) (bool, error)

GetNote gets a note for the revision specified, or nil if there is no such note.

func (*Repo) NoteRevList Uses

func (r *Repo) NoteRevList(ctx context.Context, notesRef string) (map[string]struct{}, error)

func (*Repo) Notify Uses

func (r *Repo) Notify()

Notify tells the repo that it should fetch from the origin as soon as possible. It does not block.

func (*Repo) Origin Uses

func (r *Repo) Origin() Remote

Origin returns the Remote with which the Repo was constructed.

func (*Repo) Readonly Uses

func (r *Repo) Readonly() bool

Readonly returns `true` if the repo was marked as readonly, `false` otherwise

func (*Repo) Ready Uses

func (r *Repo) Ready(ctx context.Context) error

Ready tries to advance the cloning process along as far as possible, and returns an error if it is not able to get to a ready state.

func (*Repo) Refresh Uses

func (r *Repo) Refresh(ctx context.Context) error

func (*Repo) Revision Uses

func (r *Repo) Revision(ctx context.Context, ref string) (string, error)

Revision returns the revision (SHA1) of the ref passed in

func (*Repo) Start Uses

func (r *Repo) Start(shutdown <-chan struct{}, done *sync.WaitGroup) error

Start begins synchronising the repo by cloning it, then fetching the required tags and so on.

func (*Repo) Status Uses

func (r *Repo) Status() (GitRepoStatus, error)

Status reports that readiness status of this Git repo: whether it has been cloned and is writable, and if not, the error stopping it getting to the next state.

func (*Repo) VerifyCommit Uses

func (r *Repo) VerifyCommit(ctx context.Context, commit string) error

func (*Repo) VerifyTag Uses

func (r *Repo) VerifyTag(ctx context.Context, tag string) (string, error)

type Signature Uses

type Signature struct {
    Key    string
    Status string

Signature holds information about a GPG signature.

func (*Signature) Valid Uses

func (s *Signature) Valid() bool

Valid returns true if the signature is _G_ood (valid). https://github.com/git/git/blob/56d268bafff7538f82c01d3c9c07bdc54b2993b1/Documentation/pretty-formats.txt#L146-L153

type TagAction Uses

type TagAction struct {
    Tag        string
    Revision   string
    Message    string
    SigningKey string

TagAction is a struct holding tag parameters

type Timeout Uses

type Timeout time.Duration



Package git imports 19 packages (graph) and is imported by 10 packages. Updated 2020-10-18. Refresh now. Tools for package owners.