upgrade

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (

	// MainTarget upgrades to upstream's unreleased main branch (contributor mode only).
	MainTarget = "main"
)

Variables

View Source
var ErrUnrelatedHistory = errors.New("the repository shares no history with kubriX upstream (it was probably bootstrapped with KUBRIX_BOOTSTRAP_KEEP_HISTORY=false), so it cannot be upgraded by merging")
View Source
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

func BranchName(target string) string

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

func Begin(ctx context.Context, deps Deps, repo Repo, p Progress) (*Proposal, error)

Begin clones the repository and reads the installed version and the releases to upgrade to.

func (*Proposal) Choose

func (p *Proposal) Choose(ctx context.Context, target string) (Review, error)

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) Close

func (p *Proposal) Close()

Close removes the temporary clone.

func (*Proposal) Installed

func (p *Proposal) Installed() (release string, ok bool)

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

func (p *Proposal) Propose(ctx context.Context, pr Progress) (Result, error)

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) Releases

func (p *Proposal) Releases() []string

Releases are the kubriX releases there are, newest first.

func (*Proposal) SetInstalled

func (p *Proposal) SetInstalled(release string) error

SetInstalled sets the installed release when the repository does not say.

func (*Proposal) Targets

func (p *Proposal) Targets() ([]string, error)

Targets lists what the installed release can be upgraded to, newest first: at most one major version ahead. It returns ErrUpToDate when there is nothing newer, and a *TooOldError when the installed release is below the oldest one the CLI upgrades from.

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

Jump to

Keyboard shortcuts

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