Documentation
¶
Overview ¶
Package upgrade proposes upgrading a platform repository to a newer kubriX release: it merges the release into a branch, re-renders what the release changed and opens a pull request.
A Proposal is staged. Begin clones the repository; the caller then settles the installed version (SetInstalled when the repository does not say), picks one of Targets, confirms the Review of the chosen target, and finally calls Propose. The order of the git steps behind Propose is the module's business.
Index ¶
- Constants
- Variables
- func BranchName(target string) string
- type ConflictError
- type Deps
- type Progress
- type Proposal
- func (p *Proposal) Choose(ctx context.Context, target string) (Review, error)
- func (p *Proposal) Close()
- func (p *Proposal) Installed() (release string, ok bool)
- func (p *Proposal) Propose(ctx context.Context, pr Progress) (Result, error)
- func (p *Proposal) Releases() []string
- func (p *Proposal) SetInstalled(release string) error
- func (p *Proposal) Targets() ([]string, error)
- type Repo
- type Result
- type Review
- type TooOldError
Constants ¶
const (
// MainTarget upgrades to upstream's unreleased main branch (contributor mode only).
MainTarget = "main"
)
Variables ¶
var ErrUpToDate = errors.New("already on the latest release")
ErrUpToDate means the installed release is the latest one there is to upgrade to.
Functions ¶
func BranchName ¶
Types ¶
type ConflictError ¶
type ConflictError struct{ Files []string }
ConflictError lists conflicting files that are not generated, so they need a human.
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
type Deps ¶
type Deps struct {
Host git.Host
// UpstreamURL is the clone URL of a kubriX source repository (owner/repo); GitHub's when nil.
UpstreamURL func(repo string) string
// AllowMain offers upstream's unreleased main as a target; only contributors testing kubriX want that.
AllowMain bool
}
Deps are the services a Proposal talks to.
type Progress ¶
type Progress interface {
Step(ctx context.Context, title string, fn func(context.Context) error) error
}
Progress reports the slow steps; ui.UI satisfies it.
type Proposal ¶
type Proposal struct {
// contains filtered or unexported fields
}
Proposal is an upgrade in preparation. Close it to remove the temporary clone.
func Begin ¶
Begin clones the repository and reads the installed version and the releases to upgrade to.
func (*Proposal) Choose ¶
Choose picks the target and returns what the user has to confirm. It fails with ErrUnrelatedHistory when the repository cannot be upgraded by merging.
func (*Proposal) Installed ¶
Installed is the installed kubriX release; ok is false when the repository does not say, and the caller has to ask the user and call SetInstalled.
func (*Proposal) Propose ¶
Propose merges the chosen target into a branch, re-renders the templates it changed, pushes the branch and opens a pull request. A merge conflict in files the CLI cannot regenerate stops it before anything is pushed.
func (*Proposal) SetInstalled ¶
SetInstalled sets the installed release when the repository does not say.
type Repo ¶
type Repo struct {
Org, Name string
// Upstream is the kubriX source repository (owner/repo) the platform was created from.
Upstream string
// TargetType is the platform's target type; its excluded apps are kept excluded.
TargetType string
}
Repo is the platform repository to upgrade.
type Result ¶
type Result struct {
URL, Branch string
// Regenerated are the files rendered again from changed templates.
Regenerated []string
// Resolved are conflicts in generated files that were resolved automatically; Removed are outputs of
// templates the target no longer has.
Resolved, Removed []string
// Excluded are the apps that stay excluded.
Excluded []string
}
Result is the pull request that proposes the upgrade.
type Review ¶
type Review struct {
Installed, Target string
// Notes are the release notes between the installed version and the target.
Notes string
// Breaking are the breaking-change entries of Notes, if any.
Breaking string
// Unreleased counts upstream commits after the installed release that the repository already contains:
// it was bootstrapped from a branch, so the installed version is only approximate.
Unreleased int
}
Review is what the user confirms before anything is changed.
type TooOldError ¶
type TooOldError struct{ Installed string }
TooOldError means the installed version is older than any upgrade path the CLI supports.
func (*TooOldError) Error ¶
func (e *TooOldError) Error() string