Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DockerOSMap = PlatformMap[string]{ MacOS: lo.ToPtr("linux"), Linux: lo.ToPtr("linux"), Windows: lo.ToPtr("windows"), }
DockerOSMap is a PlatformMap that defines the Docker OS for each platform.
Functions ¶
func ContainsPlatform ¶
ContainsPlatform checks if a slice of platforms contains a specific platform.
func GetArchAlias ¶ added in v1.13.0
func GetArchAlias() string
GetArchAlias returns the architecture in common alias format (x86_64 or arm64).
func GetArchGnu ¶ added in v1.13.0
func GetArchGnu() string
GetArchGnu returns the architecture in GNU/Linux format (x86_64 or aarch64).
Types ¶
type Architecture ¶ added in v1.13.0
type Architecture string
Architecture represents a CPU architecture.
const ( ArchAmd64 Architecture = "amd64" // ArchAmd64 represents x86_64 architecture. ArchArm64 Architecture = "arm64" // ArchArm64 represents ARM64 architecture. )
Constants for supported architectures.
func GetArch ¶ added in v1.13.0
func GetArch() Architecture
GetArch returns the current architecture (amd64 or arm64).
type Platform ¶
type Platform string
Platform represents an operating system platform.
const ( PlatformMacos Platform = "macos" // PlatformMacos represents macOS. PlatformLinux Platform = "linux" // PlatformLinux represents Linux. PlatformWindows Platform = "windows" // PlatformWindows represents Windows. )
Constants for supported platforms.
func GetPlatform ¶
func GetPlatform() Platform
GetPlatform returns the current platform (macos, linux, or windows).
type PlatformMap ¶
type PlatformMap[T any] struct { // MacOS is the value for macOS. MacOS *T `json:"macos" yaml:"macos"` // Linux is the value for Linux. Linux *T `json:"linux" yaml:"linux"` // Windows is the value for Windows. Windows *T `json:"windows" yaml:"windows"` }
PlatformMap is a generic type that holds platform-specific values.
func NewPlatformMap ¶ added in v1.9.0
func NewPlatformMap[T any](input any) *PlatformMap[T]
NewPlatformMap creates a new PlatformMap from either a single value or a map.
func ParsePlatformSingleValue ¶ added in v1.11.0
func ParsePlatformSingleValue[T any](value T) *PlatformMap[T]
ParsePlatformSingleValue creates a new PlatformMap with the value for all platforms
func ParselatformMap ¶ added in v1.11.0
func ParselatformMap[T any](values map[string]T) *PlatformMap[T]
ParselatformMap creates a PlatformMap from a map of platform strings to values.
func (*PlatformMap[T]) Resolve ¶
func (p *PlatformMap[T]) Resolve() *T
Resolve returns the value for the current platform from the PlatformMap. It returns nil if no value is defined for the current platform.
func (*PlatformMap[T]) ResolveWithFallback ¶
func (o *PlatformMap[T]) ResolveWithFallback(fallback PlatformMap[T]) T
ResolveWithFallback returns the value for the current platform from the PlatformMap. If no value is defined for the current platform, it falls back to the value from the provided fallback PlatformMap.
type Platforms ¶
type Platforms struct {
// Only specifies a list of platforms where the configuration should apply.
Only *[]Platform `json:"only" yaml:"only"`
// Except specifies a list of platforms where the configuration should not apply.
Except *[]Platform `json:"except" yaml:"except"`
}
Platforms defines which platforms a configuration applies to.
func (*Platforms) GetShouldRunOnOS ¶
GetShouldRunOnOS determines if a configuration should run on the current operating system based on the Only and Except fields of the Platforms struct.