chartver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchTag

func BranchTag(branch string) string

BranchTag renders a branch name the way CI does, replacing slashes with dashes (`github.ref_name | tr '/' '-'`).

func Derive

func Derive(latestTag, branch string, runID int64) (string, error)

Derive assembles the version CI would have produced, without consulting the chart index. The caller must mark the result unverified.

func Infix

func Infix(branch string) string

Infix is the marker that identifies a branch's chart versions: "-alpha-{branch}-" for a feature branch, "-rc-main-" for main.

func Match

func Match(version, branch string) bool

Match reports whether a chart version belongs to a branch.

func Newest

func Newest(versions []string, branch string) (version string, runID int64, found bool)

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

func NextTag(latestTag string) (string, error)

NextTag bumps the third dot-separated component of a git tag, mirroring the CI's `awk -F"." '{printf "%s.%s.%s", $1, $2, ++$3}'`.

func RunIDOf

func RunIDOf(version string) (int64, bool)

RunIDOf extracts the trailing run ID from a chart version.

func Search(ctx context.Context, idx Index, helmRepo, chart, branch string, update bool) (version string, runID int64, found bool, err error)

Search lists the versions published for a branch, newest first.

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.

Jump to

Keyboard shortcuts

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