versions

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package versions provides version information for the ToolHive Registry API application.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the current version of ToolHive Registry API
	Version = "dev"
	// Commit is the git commit hash of the build
	//nolint:goconst // This is a placeholder for the commit hash
	Commit = unknownStr
	// BuildDate is the date when the binary was built
	//nolint:goconst // This is a placeholder for the build date
	BuildDate = unknownStr
	// BuildType indicates if this is a release build.
	// Set to "release" only in official release builds, everything else is considered "development".
	BuildType = "development"
)

Version information set by build using -ldflags

Functions

func IsNewerVersion added in v0.6.3

func IsNewerVersion(newVersion, oldVersion string) bool

IsNewerVersion reports whether newVersion is strictly greater than oldVersion. It uses semantic versioning for comparison when both strings are valid semver, and falls back to lexicographic string comparison otherwise.

func IsPublishable added in v1.5.2

func IsPublishable(v string) bool

IsPublishable reports whether v is usable as a registry entry version.

The gate is "a three-part semantic version", matching the official registry's own semantic-version check (major.minor.patch, optional prerelease, no leading zeros). Looser versions are legal per the JSON schema, which constrains only length, but they sort unpredictably: the official registry marks anything it cannot parse as "latest" regardless of ordering, aggregators are told to fall back to publication timestamps, and IsNewerVersion degrades to lexicographic comparison. Restricting generated versions to the parseable set keeps latest-version resolution consistent across all three.

A leading "v" is accepted, since the schema lists prefixed versions as allowed. Callers should keep the value as written rather than stripping the prefix — the API matches versions exactly, and an entry's version should stay equal to the package version it was derived from.

Build metadata is rejected: semver comparison ignores it, so two versions differing only in metadata would be distinct rows that sort equal, and "+" decodes as a space in `?version=` for clients that do not percent-encode it.

Types

type VersionInfo

type VersionInfo struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	BuildDate string `json:"build_date"`
	GoVersion string `json:"go_version"`
	Platform  string `json:"platform"`
}

VersionInfo represents the version information

func GetVersionInfo

func GetVersionInfo() VersionInfo

GetVersionInfo returns the version information

Jump to

Keyboard shortcuts

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