Documentation
¶
Overview ¶
Package chartver resolves the Helm chart version CI produced for a branch.
The CI computes it as "{nextTag}-alpha-{branch}-{run_id}" for feature branches and "{nextTag}-rc-main-{run_id}" for main, where nextTag is the most recent git tag with its third component bumped. The public REST API does not expose the step summary that records it, so it is recovered here instead.
Index ¶
- func BranchTag(branch string) string
- func Derive(latestTag, branch string, runID int64) (string, error)
- func Infix(branch string) string
- func Match(version, branch string) bool
- func Newest(versions []string, branch string) (version string, runID int64, found bool)
- func NextTag(latestTag string) (string, error)
- func RunIDOf(version string) (int64, bool)
- func Search(ctx context.Context, idx Index, helmRepo, chart, branch string, update bool) (version string, runID int64, found bool, err error)
- type Index
- type Resolution
- type Strategy
- type VersionEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BranchTag ¶
BranchTag renders a branch name the way CI does, replacing slashes with dashes (`github.ref_name | tr '/' '-'`).
func Derive ¶
Derive assembles the version CI would have produced, without consulting the chart index. The caller must mark the result unverified.
func Infix ¶
Infix is the marker that identifies a branch's chart versions: "-alpha-{branch}-" for a feature branch, "-rc-main-" for main.
func Newest ¶
Newest picks the version with the highest run ID.
Ordering is by run ID, never by semver: these versions carry a pre-release suffix containing the branch name, and semver ordering compares that alphanumerically, which puts "…-9" after "…-10".
func NextTag ¶
NextTag bumps the third dot-separated component of a git tag, mirroring the CI's `awk -F"." '{printf "%s.%s.%s", $1, $2, ++$3}'`.
Types ¶
type Index ¶
type Index interface {
UpdateRepo(ctx context.Context, repo string) error
SearchVersions(ctx context.Context, repo, chart string) ([]VersionEntry, error)
}
Index is the chart-repository surface the resolver needs.
type Resolution ¶
type Resolution struct {
Version string `json:"version"`
Strategy Strategy `json:"strategy"`
RunID int64 `json:"run_id,omitempty"`
RunURL string `json:"run_url,omitempty"`
// Verified reports that the version was seen in the chart index, rather
// than computed from local tags and hope.
Verified bool `json:"verified"`
}
Resolution is a resolved chart version and how it was arrived at.
type Strategy ¶
type Strategy string
Strategy names how a version was resolved, so -v and --json can report it.
const ( // StrategyExplicit means --version short-circuited everything. StrategyExplicit Strategy = "explicit" // StrategyIndex means the version was read from the Helm repository index. StrategyIndex Strategy = "helm-index" // StrategyRun means a CI run pinned the run ID and the index confirmed it. StrategyRun Strategy = "ci-run" // StrategyDerived means the version was computed locally and not verified // against the chart repository. StrategyDerived Strategy = "derived" )
Resolution strategies, in the order they are attempted.
type VersionEntry ¶
type VersionEntry struct {
Version string
}
VersionEntry is one published chart version.