cli

package
v1.222.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

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

func WithRunner(runner atmosgit.Runner) Option

WithRunner substitutes the subprocess runner (used by tests).

func WithStderr

func WithStderr(w io.Writer) Option

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 New

func New(opts ...Option) *Provider

New constructs a CLI provider.

func (*Provider) Clone

func (p *Provider) Clone(ctx context.Context, opts *atmosgit.CloneOptions) error

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

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

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

func (p *Provider) Init(ctx context.Context, opts *atmosgit.InitOptions) error

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

func (p *Provider) Pull(ctx context.Context, opts *atmosgit.PullOptions) error

Pull fast-forwards the current branch from the remote. Fast-forward-only is a safety rule, not an option.

func (*Provider) Push

func (p *Provider) Push(ctx context.Context, opts *atmosgit.PushOptions) error

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

Status reports porcelain status, optionally scoped to paths.

func (*Provider) SwapStderr

func (p *Provider) SwapStderr(w io.Writer) func()

SwapStderr replaces the stderr writer and returns a restore function.

Jump to

Keyboard shortcuts

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