latest

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 16 Imported by: 1

README

Latest

Latest is a Go library to help you find the latest available versions of things.

It currently supports finding the:

  • Latest tag in a git repository
  • Latest tag in a container image repository
  • Latest digest of a tag in a container image repository
  • Latest release of Go (along with download URL and checksum)
  • Latest release of Postgres (along with download URL and checksum)
  • Latest release of Alpine Linux (along with download URL and checksum)
  • Latest version of an Alpine package (along with download URL and dependencies)
  • Latest info for all Alpine packages in a repository

For examples of each, see the examples directory.

Contributions of/requests for other sources welcome!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlpinePackage

func AlpinePackage(ctx context.Context, pkg string, options *AlpinePackageOptions) (latestVersion, downloadUrl string, dependencies []string, err error)

AlpinePackage retrieves the latest version of the given package, the url it can be downloaded from, and the names of its declared dependencies. It does not return a checksum as the APK files themselves can be verified using their signatures.

Knowing the latest version of a package involves downloading and parsing the APKINDEX file, which is a moderately expensive operation. If you are calling this func multiple times, you should populate the Cache option with a cache that will maintain state. See NewInMemoryAlpinePackageCache for a simple in-memory cache that will suffice for most purposes.

If calling this func with multiple different options (such as repository, branch or architecture), care should be given to ensure that a unique cache is provided for each combination.

pkg can be a package name, or any token that is provided by a package, e.g. "so:libssl.so.3" or "cmd:busybox".

func AlpinePackages

func AlpinePackages(ctx context.Context, options *AlpinePackagesOptions) (map[string]*AlpinePackageInfo, error)

AlpinePackages retrieves the latest list of packages available from an Alpine Linux repository.

func AlpineRelease

func AlpineRelease(ctx context.Context, options *AlpineReleaseOptions) (latestVersion, downloadUrl, downloadChecksum string, err error)

AlpineRelease finds the latest release of Alpine Linux, returning the version, download URL and file checksum.

func GitTag

func GitTag(ctx context.Context, repo string, options *TagOptions) (string, error)

GitTag lists the tags available in the specified repository, and returns the latest semver tag.

The repository must be specified as an HTTP/HTTPS url.

func GoRelease

func GoRelease(ctx context.Context, options *GoOptions) (latestVersion, downloadUrl, downloadChecksum string, err error)

GoRelease finds the latest release of Go, returning the version, download URL and file checksum.

func ImageDigest

func ImageDigest(ctx context.Context, name string, options *ImageOptions) (string, error)

ImageDigest queries an image registry and returns the latest digest of an image with the given name.

func ImageTag

func ImageTag(ctx context.Context, name string, options *ImageTagOptions) (string, error)

ImageTag queries an image registry for the available tags for the given image, and returns the latest semver tag.

func PostgresRelease

func PostgresRelease(ctx context.Context, options *TagOptions) (latest, url, checksum string, err error)

Types

type AlpinePackageCache

type AlpinePackageCache interface {
	// Put stores the given data in the cache
	Put(map[string]*AlpinePackageInfo) error
	// Get retrieves the existing cached data, or an empty map if not available
	Get() (map[string]*AlpinePackageInfo, error)
}

AlpinePackageCache facilitates storing information about available Alpine packages between calls of AlpinePackage.

func NewInMemoryAlpinePackageCache

func NewInMemoryAlpinePackageCache() AlpinePackageCache

NewInMemoryAlpinePackageCache creates a new AlpinePackageCache that simply stores the package data in memory.

type AlpinePackageInfo

type AlpinePackageInfo = apkutils.PackageInfo

type AlpinePackageOptions

type AlpinePackageOptions struct {
	AlpinePackagesOptions

	// The cache to use for persisting package information. Defaults to a new
	// in-memory cache, which will cause the package list to be updated every
	// time AlpinePackage is called.
	Cache AlpinePackageCache
}

AlpinePackageOptions defines options for calls to AlpinePackage

type AlpinePackagesOptions

type AlpinePackagesOptions struct {
	// The provider for Alpine Linux public keys, used to verify the signature of the APKINDEX.
	// Defaults to using all known keys provided by apkutil.
	KeyProvider apkutils.KeyProvider
	// The alpine mirror to use. Defaults to `https://dl-cdn.alpinelinux.org/alpine/`
	Mirror string
	// The architecture to use. Defaults to "x86_64".
	Arch string
	// The alpine branch to get packages for. Defaults to "latest-stable"
	Branch string
	// The alpine repository to get packages from. Defaults to "main"
	Repository string
}

AlpinePackagesOptions defines options for calls to AlpinePackages

type AlpineReleaseOptions

type AlpineReleaseOptions struct {
	// The alpine mirror to use. Defaults to `https://dl-cdn.alpinelinux.org/alpine/`
	Mirror string
	// The architecture to select. Defaults to "x86_64".
	Arch string
	// The flavour of alpine to return download links and checksums for. Defaults to "standard".
	Flavour string
}

AlpineReleaseOptions defines options for calls to AlpineRelease

type GoOptions

type GoOptions struct {
	// If set, only return files for this OS.
	Os string
	// If set, only return files for this Architecture.
	Arch string
	// The kind of file to return. Defaults to "source".
	//
	// Valid kinds at time of writing are: "source", "archive" and "installer".
	Kind string
}

GoOptions defines options for calling GoRelease.

type ImageOptions

type ImageOptions struct {
	// The registry to use if image names aren't fully-qualified.
	// Defaults to "docker.io".
	Registry string
	// The username to use to authenticate to registries.
	// If not set, will attempt to use the docker config file.
	Username string
	// The password to use to authenticate to registries.
	// If not set, will attempt to use the docker config file.
	Password string
}

ImageOptions defines options for image-related functions.

type ImageTagOptions

type ImageTagOptions struct {
	ImageOptions
	TagOptions
}

ImageTagOptions defines the options for calls to ImageTag.

type TagOptions

type TagOptions struct {
	// Should tags that look like dates (starting yyyymmdd or yyyy-mm-dd) be ignored?
	IgnoreDates bool
	// Should tags that are not parseable as semver be silently ignored?
	IgnoreErrors bool
	// Should pre-releases (-alpha, -beta, etc) be ignored?
	IgnorePreRelease bool
	// Strings to remove from the start of tags. Processed in order.
	TrimPrefixes []string
	// Strings to remove from the ends of tags. Processed in order.
	TrimSuffixes []string
	// The maximum major version to consider.
	MajorVersionMax int
}

TagOptions defines options for functions that need to deal with semver tags.

Directories

Path Synopsis
examples
alpine-package command
alpine-release command
git-tag command
go-release command
image-digest command
image-tag command

Jump to

Keyboard shortcuts

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