platform

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CacheFileName is the name of the platform cache file
	CacheFileName = "platforms.json"

	// CacheTTL is how long cached platform info is considered valid
	CacheTTL = 24 * time.Hour
)
View Source
const (
	// HomebrewVersionURL is the URL to Homebrew's macOS version definitions
	HomebrewVersionURL = "https://raw.githubusercontent.com/Homebrew/brew/master/Library/Homebrew/macos_version.rb"

	// MinSupportedMacOSMajor is the minimum macOS version we generate bottles for
	// Apple supports ~3 years of macOS versions
	MinSupportedMacOSMajor = 12 // Monterey
)

Variables

This section is empty.

Functions

func FormatPlatformList

func FormatPlatformList(info *PlatformInfo) string

FormatPlatformList returns a human-readable list of platforms

func ParsePlatformTag

func ParsePlatformTag(tag string) (os, arch, version string)

ParsePlatformTag parses a Homebrew platform tag into OS, arch, and version

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache manages platform information caching

func NewCache

func NewCache(cacheDir string) (*Cache, error)

NewCache creates a new platform cache

func (*Cache) Age

func (c *Cache) Age() time.Duration

Age returns how old the cache is, or -1 if no cache exists

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes the cache file

func (*Cache) Load

func (c *Cache) Load() (*PlatformInfo, error)

Load loads platform info from cache if valid and not expired

func (*Cache) LoadExpired

func (c *Cache) LoadExpired() (*PlatformInfo, error)

LoadExpired loads platform info from cache even if expired

func (*Cache) Path

func (c *Cache) Path() string

Path returns the cache file path

func (*Cache) Save

func (c *Cache) Save(info *PlatformInfo) error

Save saves platform info to cache

type CachedPlatformInfo

type CachedPlatformInfo struct {
	PlatformInfo
	CachedAt time.Time `json:"cached_at"`
}

CachedPlatformInfo wraps PlatformInfo with cache metadata

type Discoverer

type Discoverer struct {
	// contains filtered or unexported fields
}

Discoverer fetches current platform information from Homebrew's source

func NewDiscoverer

func NewDiscoverer(cacheDir string) (*Discoverer, error)

NewDiscoverer creates a new platform discoverer

func (*Discoverer) Discover

func (d *Discoverer) Discover(ctx context.Context, forceRefresh bool) (*PlatformInfo, error)

Discover fetches current supported platforms from Homebrew If forceRefresh is false, returns cached data if available and not expired

func (*Discoverer) GetPlatformsForArtifact

func (d *Discoverer) GetPlatformsForArtifact(ctx context.Context, goos, goarch string, forceRefresh bool) ([]Platform, error)

GetPlatformsForArtifact returns all Homebrew platforms compatible with a GOOS/GOARCH

type MacOSVersion

type MacOSVersion struct {
	Major  int    // e.g., 15
	Symbol string // e.g., "sequoia"
}

MacOSVersion represents a macOS version with its codename

func (MacOSVersion) String

func (v MacOSVersion) String() string

type Platform

type Platform struct {
	Tag            string // e.g., "arm64_sonoma", "x86_64_linux"
	OS             string // "darwin" or "linux"
	Arch           string // "amd64" or "arm64"
	OSVersion      string // e.g., "sonoma", "ventura" (macOS codename), or empty for Linux
	OSVersionMajor int    // e.g., 14 for sonoma; 0 for Linux
}

Platform represents a Homebrew bottle platform tag

func FilterPlatforms

func FilterPlatforms(platforms []Platform, include, exclude []string) []Platform

FilterPlatforms filters platforms based on include/exclude lists

func (Platform) String

func (p Platform) String() string

type PlatformInfo

type PlatformInfo struct {
	MacOSVersions []MacOSVersion // Supported macOS versions (newest first)
	LinuxArches   []string       // e.g., ["x86_64", "aarch64"]
}

PlatformInfo holds discovered platform information

func DefaultPlatformInfo

func DefaultPlatformInfo() *PlatformInfo

DefaultPlatformInfo returns a fallback platform info if discovery fails. Only includes macOS versions currently supported by Apple/Homebrew (past 3 releases).

func (*PlatformInfo) AllPlatforms

func (pi *PlatformInfo) AllPlatforms() []Platform

AllPlatforms returns all possible platform tags

func (*PlatformInfo) GetPlatformsForOS

func (pi *PlatformInfo) GetPlatformsForOS(goos, goarch string) []Platform

GetPlatformsForOS returns the Homebrew platform tag for a given OS/arch. For macOS, returns only the oldest supported version (e.g., monterey). Homebrew's fallback mechanism allows older bottles to install on newer macOS.

Jump to

Keyboard shortcuts

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