Categorygithub.com/containerd/platforms
modulepackage
1.0.0-rc.0
Repository: https://github.com/containerd/platforms.git
Documentation: pkg.go.dev

# README

platforms

A Go package for formatting, normalizing and matching container platforms.

This package is based on the Open Containers Image Spec definition of a platform.

Platform Specifier

While the OCI platform specifications provide a tool for components to specify structured information, user input typically doesn't need the full context and much can be inferred. To solve this problem, this package introduces "specifiers". A specifier has the format <os>|<arch>|<os>/<arch>[/<variant>]. The user can provide either the operating system or the architecture or both.

An example of a common specifier is linux/amd64. If the host has a default runtime that matches this, the user can simply provide the component that matters. For example, if an image provides amd64 and arm64 support, the operating system, linux can be inferred, so they only have to provide arm64 or amd64. Similar behavior is implemented for operating systems, where the architecture may be known but a runtime may support images from different operating systems.

Project details

platforms is a containerd sub-project, licensed under the Apache 2.0 license. As a containerd sub-project, you will find the:

information in our containerd/project repository.

# Functions

Any returns a platform MatchComparer which matches any of the platforms with no preference for ordering.
Default returns the default matcher for the platform.
DefaultSpec returns the current platform's default platform specification.
DefaultStrict returns strict form of Default.
DefaultString returns the default string specifier for the platform, with [PR#6](https://github.com/containerd/platforms/pull/6) the result may now also include the OSVersion from the provided platform specification.
Format returns a string specifier from the provided platform specification.
FormatAll returns a string specifier that also includes the OSVersion from the provided platform specification.
MustParse is like Parses but panics if the specifier cannot be parsed.
NewMatcher returns a simple matcher based on the provided platform specification.
Normalize validates and translate the platform to the canonical value.
Only returns a match comparer for a single platform using default resolution logic for the platform.
OnlyStrict returns a match comparer for a single platform.
Ordered returns a platform MatchComparer which matches any of the platforms but orders them in order they are provided.
Parse parses the platform specifier syntax into a platform declaration.
ParseAll parses a list of platform specifiers into a list of platform.

# Variables

All is a platform MatchComparer which matches all platforms with preference for ordering.

# Interfaces

MatchComparer is able to match and compare platforms to filter and sort platforms.
Matcher matches platforms specifications, provided by an image or runtime.

# Type aliases

Platform is a type alias for convenience, so there is no need to import image-spec package everywhere.