version

package
v1.223.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package version resolves the latest allowed upstream version for a vendored Git source: it lists remote tags, parses semantic versions, and applies the configured version constraints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractGitURI

func ExtractGitURI(source string) string

ExtractGitURI extracts a clean Git URI from a vendor source string. It handles `git::` prefixes, `github.com/` shorthand, query parameters, and `.git` suffixes so the result can be handed to a remote lister.

func FilterBySemverConstraint

func FilterBySemverConstraint(versions []string, constraint string) ([]string, error)

FilterBySemverConstraint keeps only versions matching the semver constraint.

func FilterExcludedVersions

func FilterExcludedVersions(versions, excluded []string) []string

FilterExcludedVersions removes versions matching any exclusion pattern.

func FilterPrereleases

func FilterPrereleases(versions []string) []string

FilterPrereleases removes pre-release versions; non-semver values are kept.

func FindLatestSemVerTag

func FindLatestSemVerTag(tags []string) (*semver.Version, string)

FindLatestSemVerTag returns the highest semantic version among tags and the original tag string for it. Non-semver tags are ignored.

func IsGitSource

func IsGitSource(source string) bool

IsGitSource reports whether a vendor source string looks like a Git repository (the only source type supported by update/diff in the initial version).

func IsTemplatedVersion

func IsTemplatedVersion(version string) bool

IsTemplatedVersion reports whether a version string contains Go template syntax (e.g. `{{.Version}}`) and therefore must be skipped by update.

func IsValidCommitSHA

func IsValidCommitSHA(ref string) bool

IsValidCommitSHA reports whether ref looks like a Git commit SHA (7-40 hex chars).

func MatchesWildcard

func MatchesWildcard(version, pattern string) bool

MatchesWildcard reports whether version matches pattern, which may be an exact value or a trailing-wildcard prefix such as "1.5.*".

func ParseSemVer

func ParseSemVer(version string) (*semver.Version, error)

ParseSemVer parses a version string as a semantic version, tolerating a leading `v`/`V` prefix.

func ResolveVersionConstraints

func ResolveVersionConstraints(availableVersions []string, constraints *schema.VendorConstraints) (string, error)

ResolveVersionConstraints applies the configured constraints to a list of available versions and returns the latest version that satisfies them all.

func SelectLatestVersion

func SelectLatestVersion(versions []string) (string, error)

SelectLatestVersion returns the highest semver value from versions, falling back to the first entry when none parse as semver.

Types

type GoGitLister

type GoGitLister struct{}

GoGitLister lists remote tags using go-git's in-memory remote (no shelling out to the `git` binary, no working tree). Public repositories work without auth; private repositories are out of scope for the initial version.

func (*GoGitLister) ListTags

func (l *GoGitLister) ListTags(ctx context.Context, gitURI string) ([]string, error)

ListTags returns the short tag names advertised by the remote at gitURI.

type RemoteLister

type RemoteLister interface {
	ListTags(ctx context.Context, gitURI string) ([]string, error)
}

RemoteLister lists tag names from a remote Git repository. It is an interface so update logic can be unit-tested without network access.

var DefaultLister RemoteLister = &GoGitLister{}

DefaultLister is the production RemoteLister backed by go-git.

Jump to

Keyboard shortcuts

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