Documentation
¶
Overview ¶
Package cli implements the Git CLI provider: the universal, host-agnostic execution backend that shells out to git. It is the only v1 provider, chosen because GitHub STS materializes credentials as GIT_CONFIG_* environment variables, which subprocess git honors (and go-git ignores).
Index ¶
- type Option
- type Provider
- func (p *Provider) Clone(ctx context.Context, opts *atmosgit.CloneOptions) error
- func (p *Provider) Commit(ctx context.Context, opts *atmosgit.CommitOptions) (*atmosgit.CommitResult, error)
- func (p *Provider) Diff(ctx context.Context, opts *atmosgit.DiffOptions) (*atmosgit.DiffResult, error)
- func (p *Provider) Init(ctx context.Context, opts *atmosgit.InitOptions) error
- func (p *Provider) Pull(ctx context.Context, opts *atmosgit.PullOptions) error
- func (p *Provider) Push(ctx context.Context, opts *atmosgit.PushOptions) error
- func (p *Provider) Status(ctx context.Context, opts *atmosgit.StatusOptions) (*atmosgit.StatusResult, error)
- func (p *Provider) SwapStderr(w io.Writer) func()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Provider)
Option configures the Provider (functional options pattern).
func WithRunner ¶
WithRunner substitutes the subprocess runner (used by tests).
func WithStderr ¶
WithStderr directs subprocess stderr to a writer. Production callers pass a masked writer from pkg/io so secrets are masked at write time; stderr is never embedded in error chains.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider executes Git operations via the git CLI.
func (*Provider) Clone ¶
Clone reconciles a repository workdir: a fresh clone when the workdir is absent, otherwise fetch and fast-forward to the expected ref. Reconcile makes clone behavior independent of cache freshness (CI cache restores may be stale).
func (*Provider) Commit ¶
func (p *Provider) Commit(ctx context.Context, opts *atmosgit.CommitOptions) (*atmosgit.CommitResult, error)
Commit stages managed paths (when given) and creates a commit. A commit with nothing to commit is a clean no-op: Committed=false, nil error.
func (*Provider) Diff ¶
func (p *Provider) Diff(ctx context.Context, opts *atmosgit.DiffOptions) (*atmosgit.DiffResult, error)
Diff reports the difference between the worktree and HEAD: a unified diff of tracked changes plus the list of untracked files. This is the read-before-write step for GitOps publishing.
func (*Provider) Init ¶
Init creates a repository workdir — the inverse of Clone, for GitOps repositories whose remote has no content yet.
Init is idempotent for the empty (no --from) mode: re-running it against an already-initialized repository reconciles in place (`git init` is idempotent and the configured remote is updated rather than duplicated). --force means "redo from scratch": the existing workdir is deleted and re-initialized.
func (*Provider) Pull ¶
Pull fast-forwards the current branch from the remote. Fast-forward-only is a safety rule, not an option.
func (*Provider) Push ¶
Push pushes the current branch, retrying on non-fast-forward rejection — the most common GitOps publishing failure (a concurrent publisher pushed first). Each retry rebases local commits onto the updated remote ref and pushes again, bounded by opts.Retries. Atmos never force-pushes.
func (*Provider) Status ¶
func (p *Provider) Status(ctx context.Context, opts *atmosgit.StatusOptions) (*atmosgit.StatusResult, error)
Status reports porcelain status, optionally scoped to paths.
func (*Provider) SwapStderr ¶
SwapStderr replaces the stderr writer and returns a restore function.