platform

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Overview

Package platform handles the parsing and comparing of the image platform (e.g. linux/amd64)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compatible added in v0.4.5

func Compatible(host, target Platform) bool

Compatible indicates if a host can run a specified target platform image. This accounts for Docker Desktop for Mac and Windows using a Linux VM.

func Match

func Match(a, b Platform) bool

Match indicates if two platforms are the same.

func NewCompare added in v0.6.0

func NewCompare(host Platform, opts ...CompareOpts) *compare

NewCompare is used to compare multiple target entries to a host value.

Types

type CompareOpts added in v0.6.0

type CompareOpts func(*compare)

type Platform

type Platform struct {
	// Architecture field specifies the CPU architecture, for example `amd64` or `ppc64`.
	Architecture string `json:"architecture"`

	// OS specifies the operating system, for example `linux` or `windows`.
	OS string `json:"os"`

	// OSVersion is an optional field specifying the operating system version, for example `10.0.10586`.
	OSVersion string `json:"os.version,omitempty"`

	// OSFeatures is an optional field specifying an array of strings, each listing a required OS feature (for example on Windows `win32k`).
	OSFeatures []string `json:"os.features,omitempty"`

	// Variant is an optional field specifying a variant of the CPU, for example `ppc64le` to specify a little-endian version of a PowerPC CPU.
	Variant string `json:"variant,omitempty"`

	// Features is an optional field specifying an array of strings, each listing a required CPU feature (for example `sse4` or `aes`).
	Features []string `json:"features,omitempty"`
}

Platform specifies a platform where a particular image manifest is applicable.

func Local

func Local() Platform

Local retrieves the local platform details

func Parse

func Parse(platStr string) (Platform, error)

Parse converts a platform string into a struct

func (Platform) String

func (p Platform) String() string

String outputs the platform in the <os>/<arch>/<variant> notation

Jump to

Keyboard shortcuts

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