Documentation
¶
Overview ¶
Package gitops gives the reservation commands one way to find the GitOps repo: a checkout on disk, fast-forwarded to origin/main before any command logic runs. The tip of main is the only source of truth; no command reads or writes a cluster.
Index ¶
- Constants
- func IsInvalidFlag(err error) bool
- func IsPushFailed(err error) bool
- func IsSync(err error) bool
- func Sync(ctx context.Context, dir string, stderr io.Writer) error
- func User(ctx context.Context, user string, stderr io.Writer) (string, error)
- func UserHelp(what string) string
- func WriteJSON(w io.Writer, v any) error
- type Checkout
- type Flags
Constants ¶
const ( FlagRepo = "gitops-repo" FlagDir = "gitops-dir" FlagDryRun = "dry-run" FlagOutput = "output" OutputTable = "table" OutputJSON = "json" // EnvTargetDir is the umbrella checkout directory; the GitOps repo lives in // its cmc/<repo> subdirectory. EnvTargetDir = "UMBRELLA_TARGET_DIR" // DefaultRepo holds the configuration of every Giant Swarm management // cluster. DefaultRepo = reservation.DefaultGitOpsRepository )
const CheckoutHelp = `The command works on a checkout of the GitOps repository: --gitops-dir, or $` + EnvTargetDir + `/cmc/<repo> when that is empty, where <repo> is the name part of --gitops-repo. It never clones. First it fast-forwards the checkout to origin/main. It stops when the checkout is not on main, has changes to tracked files, or has local commits that are not on origin/main. It leaves untracked files alone. Git uses the checkout's own credentials.`
CheckoutHelp is the paragraph every reservation command's long help carries about the GitOps checkout.
Variables ¶
This section is empty.
Functions ¶
func Sync ¶
Sync brings dir to the tip of origin/main, or stops with the reason it cannot do that safely.
func User ¶
User returns user when it is set, and otherwise the login of the GitHub token devctl acts with. A GitHub App installation token has no login, so a caller that acts with one passes --user.
Types ¶
type Checkout ¶
type Checkout struct {
Dir string
// contains filtered or unexported fields
}
Checkout is a GitOps checkout that has been synced to origin/main.
func (*Checkout) Explain ¶
Explain turns the errors the user can act on into messages that say so: a directory that is not a GitOps repo names what selected it, and a push that gave up says the change is not in effect and how to clear the local commit. Any other error comes back as it is.
func (*Checkout) Finish ¶
Finish ends the command. After a dry run it shows the commits the command made on stderr and resets the checkout to origin/main, even when err is set. Open left the checkout clean on origin/main, so the reset drops only what the command wrote. It returns err, or the reset's error when err is nil.
type Flags ¶
Flags select the GitOps repo and where its checkout is, and the flags every reservation command shares: how to print the result and, for a command that pushes, whether to push.
func (*Flags) InitDryRun ¶
InitDryRun adds --dry-run, for a command that pushes.
func (*Flags) Open ¶
Open resolves the checkout and syncs it to origin/main. It runs before any command logic, list included. Git uses the checkout's own credentials.