build

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: AGPL-3.0 Imports: 34 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (

	// Win11OfflineEnv disables every attempt to reach Microsoft (CI build jobs).
	Win11OfflineEnv = "SAILWRIGHT_WIN11_ISO_OFFLINE"
)

Variables

View Source
var ErrMicrosoftRefused = errors.New("microsoft refused the Windows 11 download request")

ErrMicrosoftRefused signals that Microsoft rejected or challenged the request (e.g. datacenter IP). It is a neutral outcome, not a code defect.

Functions

func AvailableVirtualMachineConfigsForCurrentHostOSByVirtualizationEngine added in v0.4.0

func AvailableVirtualMachineConfigsForCurrentHostOSByVirtualizationEngine() map[VirtualizationEngine][]VirtualMachineConfig

func BuildArtifactsExist added in v0.4.0

func BuildArtifactsExist(config VirtualMachineConfig) (bool, error)

func BuildArtifactsExistQuiet added in v0.4.0

func BuildArtifactsExistQuiet(config VirtualMachineConfig) (bool, error)

func DependencyReconciliation

func DependencyReconciliation(vmconfig VirtualMachineConfig)

func DisplayVirtualizationEngine added in v0.8.0

func DisplayVirtualizationEngine(engine VirtualizationEngine) string

func DownloadWin11ISO added in v0.20.0

func DownloadWin11ISO(url, dst, expectedSHA256 string) error

DownloadWin11ISO downloads the ISO to dst (go-getter, progress, checksum retry) and verifies sha256 when given.

func FetchLatestWin11Release added in v0.20.0

func FetchLatestWin11Release() (string, error)

FetchLatestWin11Release queries the public release notes for the newest Windows 11 release.

func GenerateVirtualMachineSlug

func GenerateVirtualMachineSlug(config *VirtualMachineConfig) string

func GetVirtualMachineNameWithType

func GetVirtualMachineNameWithType(config VirtualMachineConfig) string

func GetVmCpuCount added in v0.3.0

func GetVmCpuCount(config VirtualMachineConfig) int

GetVmCpuCount returns the resolved CPU count for the given VM config.

func GetVmMemoryMB added in v0.3.0

func GetVmMemoryMB(config VirtualMachineConfig) int

GetVmMemoryMB returns the resolved memory allocation in megabytes for the given VM config.

func GroupVirtualMachineConfigsByVirtualizationEngine added in v0.4.0

func GroupVirtualMachineConfigsByVirtualizationEngine(configs []VirtualMachineConfig) map[VirtualizationEngine][]VirtualMachineConfig

func HashFile added in v0.20.0

func HashFile(file string) (string, int64, error)

HashFile returns the sha256 hex digest and size of a file.

func IsVirtualizationEngineUnstable added in v0.8.0

func IsVirtualizationEngineUnstable(engine VirtualizationEngine) bool

func ParseWin11Build added in v0.20.0

func ParseWin11Build(sourceName string) string

ParseWin11Build extracts the build (e.g. "26300.9457") from Microsoft's ISO file name; "" if unknown.

func ParseWin11Release added in v0.20.0

func ParseWin11Release(sourceName string) string

ParseWin11Release extracts the release (e.g. "25H2") from Microsoft's ISO file name; "" if unknown.

func ProbeWin11ISO added in v0.20.0

func ProbeWin11ISO(url string) (int64, error)

ProbeWin11ISO returns the size of the ISO behind url without downloading it. It tries HEAD first and falls back to a one-byte ranged GET, because signed CDN URLs sometimes reject HEAD or omit Content-Length.

func RemoveBuildArtifacts

func RemoveBuildArtifacts(artifacts []string)

func RemoveBuildArtifactsForConfig

func RemoveBuildArtifactsForConfig(config VirtualMachineConfig)

func RunBashScript

func RunBashScript(config RunProcessConfig) error

func RunBuildScript

func RunBuildScript(config VirtualMachineConfig, executable string, args []string, extraEnv ...string) (err error)

RunBuildScript runs a build script with the managed environment plus extraEnv.

func RunCliCommand added in v0.2.0

func RunCliCommand(workdir string, command string, args []string) ([]byte, error)

func RunCliCommandWithEnv added in v0.12.0

func RunCliCommandWithEnv(workdir string, command string, args []string, env []string) ([]byte, error)

func RunExternalProcess

func RunExternalProcess(config RunProcessConfig) (context.Context, error)

func RunExternalProcessWithRetries

func RunExternalProcessWithRetries(config RunProcessConfig) context.Context

func RunFfmpegVideoGenerationProcess

func RunFfmpegVideoGenerationProcess(vm_config VirtualMachineConfig, ctx context.Context, process_config RunProcessConfig, recording_config *VncRecordingConfig) context.Context

func RunHypervUbuntuBuildOnWindows added in v0.3.0

func RunHypervUbuntuBuildOnWindows(config VirtualMachineConfig) error

RunHypervUbuntuBuildOnWindows builds an Ubuntu VM using Hyper-V on Windows.

func RunHypervWindowsBuildOnWindows added in v0.2.0

func RunHypervWindowsBuildOnWindows(config VirtualMachineConfig) error

RunHypervWindowsBuildOnWindows builds a Windows 11 VM using Hyper-V on Windows. It retries early failures to handle the transient "No ip address" race condition in the Packer HyperV plugin: StepRun calls GetHostAdapterIpAddressForSwitch with no retry, and attaching a new VM to the Default Switch can briefly disrupt the host adapter's IPv4 address. This failure always occurs within the first ~30 seconds; real build failures take 30+ minutes. Retries are skipped for long-running failures to avoid wasting CI time on genuine errors.

func RunPowerShellScript added in v0.2.0

func RunPowerShellScript(config RunProcessConfig) error

func RunQemuUbuntuBuildOnLinux added in v0.12.0

func RunQemuUbuntuBuildOnLinux(config VirtualMachineConfig) error

func RunQemuUbuntuBuildOnMacOS

func RunQemuUbuntuBuildOnMacOS(config VirtualMachineConfig) error

func RunQemuWindowsBuildOnLinux added in v0.14.0

func RunQemuWindowsBuildOnLinux(config VirtualMachineConfig) error

func RunQemuWindowsBuildOnMacOS

func RunQemuWindowsBuildOnMacOS(config VirtualMachineConfig) error

func RunVirtualBoxWindowsBuildOnWindows added in v0.2.0

func RunVirtualBoxWindowsBuildOnWindows(config VirtualMachineConfig) error

RunVirtualBoxWindowsBuildOnWindows builds a Windows 11 VM using VirtualBox on Windows.

func RunVncSnapshotProcess

func RunVncSnapshotProcess(vm_config VirtualMachineConfig, ctx context.Context, process_config RunProcessConfig, recording_config *VncRecordingConfig) context.Context

func VncSnapshotDir added in v0.19.0

func VncSnapshotDir(cacheDir string, vm_config VirtualMachineConfig) string

VncSnapshotDir is where the VNC snapshot process stores console frames for a VM. sailwright-gateway mirrors this layout without importing this package; a test in internal/gateway keeps both in sync.

func Win11ISOOffline added in v0.20.0

func Win11ISOOffline() bool

Win11ISOOffline reports whether Microsoft access is disabled (CI build jobs).

func Win11ObjectName added in v0.20.0

func Win11ObjectName(sourceName, arch string, firstSeen time.Time) string

Win11ObjectName builds the immutable remote object name from Microsoft's file name and the first-seen date. Unexpected source names use the requested architecture (amd64 or arm64) in the fallback.

func Win11RefreshDue added in v0.20.0

func Win11RefreshDue(m *Win11Manifest, now time.Time, latestRelease string, force bool) (bool, string)

Win11RefreshDue decides offline whether contacting Microsoft is worthwhile. latestRelease is the newest release announced by the release notes ("" if unknown). A newer announcement triggers one check only: announcements without general ISO media (e.g. device-specific releases) would otherwise contact Microsoft on every run. After that check, the age rule picks up media that Microsoft publishes later.

func Win11SourceNameFromURL added in v0.20.0

func Win11SourceNameFromURL(rawURL string) string

Win11SourceNameFromURL returns Microsoft's file name (the URL path basename, ignoring the query string).

Types

type Directories

type Directories struct {
	WorkingDir     string
	ProjectDir     string
	AppDataDir     string
	ConfigDir      string
	CacheDir       string
	VagrantDir     string
	PackerCacheDir string
}

func GetDirectoriesInstance

func GetDirectoriesInstance() *Directories

func (*Directories) CachePath added in v0.8.0

func (u *Directories) CachePath(paths ...string) string

func (*Directories) ConfigPath added in v0.16.1

func (u *Directories) ConfigPath(paths ...string) string

func (*Directories) GetDirectories

func (u *Directories) GetDirectories() Directories

func (*Directories) ManagedEnv added in v0.8.0

func (u *Directories) ManagedEnv() []string

func (*Directories) PackerCachePath added in v0.8.0

func (u *Directories) PackerCachePath(paths ...string) string

func (*Directories) VagrantPath added in v0.8.0

func (u *Directories) VagrantPath(paths ...string) string

type HostOsType added in v0.2.0

type HostOsType string
const (
	HostOsLinux   HostOsType = "debian"
	HostOsWindows HostOsType = "windows"
	HostOsDarwin  HostOsType = "darwin"
)

func GetCurrentHostOs added in v0.2.0

func GetCurrentHostOs() HostOsType

type ProgressBarListener

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

ProgressBarListener implements getter.ProgressListener using an mpb container so that concurrent downloads render their bars cleanly on separate lines.

func (*ProgressBarListener) TrackProgress

func (p *ProgressBarListener) TrackProgress(src string, current, total int64, r io.ReadCloser) io.ReadCloser

type RunProcessConfig

type RunProcessConfig struct {
	ExecutablePath     string
	Args               []string
	Env                []string
	WorkingDir         string
	Timeout            time.Duration
	DelayBeforeStart   time.Duration
	Context            context.Context
	FailOnError        bool
	Retries            int
	RetryInterval      time.Duration
	InterruptRetryChan chan bool
	Silent             *atomic.Bool
}

type VirtualMachineConfig

type VirtualMachineConfig struct {
	OS                     string
	Arch                   string
	UbuntuType             string
	VncPort                int
	Slug                   string
	ExpectedBuildArtifacts []string
	StagedBuildArtifacts   []string
	NoCache                bool
	HostOs                 HostOsType
	VirtualizationEngine   VirtualizationEngine
	Cpus                   int
	// MemoryMB is the desired VM memory in megabytes.
	// When 0 (the default), memory is calculated automatically:
	// max(4096, totalSystemMemoryMB - 4096).
	MemoryMB int
	Headless bool
	Verbose  bool
}

func AvailableVirtualMachineConfigs

func AvailableVirtualMachineConfigs() []VirtualMachineConfig

func AvailableVirtualMachineConfigsForCurrentHostOS added in v0.2.0

func AvailableVirtualMachineConfigsForCurrentHostOS() []VirtualMachineConfig

func AvailableVirtualMachineConfigsForHostOS added in v0.4.0

func AvailableVirtualMachineConfigsForHostOS(hostOs HostOsType) []VirtualMachineConfig

type VirtualizationEngine added in v0.2.0

type VirtualizationEngine string
const (
	VirtualizationEngineQemu       VirtualizationEngine = "qemu"
	VirtualizationEngineTart       VirtualizationEngine = "tart"
	VirtualizationEngineUtm        VirtualizationEngine = "utm"
	VirtualizationEngineHyperv     VirtualizationEngine = "hyperv"
	VirtualizationEngineVirtualBox VirtualizationEngine = "virtualbox"
)

func CurrentHostVirtualizationEngines added in v0.4.0

func CurrentHostVirtualizationEngines() []VirtualizationEngine

func VirtualizationEnginesForVirtualMachineConfigs added in v0.4.0

func VirtualizationEnginesForVirtualMachineConfigs(configs []VirtualMachineConfig) []VirtualizationEngine

type VncRecordingConfig

type VncRecordingConfig struct {
	OutputFile      string
	OutputFolder    string
	OutputVideoFile string
	Password        string
	StreamedToVideo bool
}

type WebFileDependency

type WebFileDependency struct {
	LocalPath        string
	Checksum         string
	Source           string
	FallbackSources  []string
	RelatedVmConfigs []VirtualMachineConfig
	// BeforeHook is a function that is called before downloading the dependency. It can be used to modify the Source URL dynamically.
	BeforeHook func() (string, error)
	// FailureHint is appended to the error when every source fails.
	FailureHint string
}

type Win11HistoryEntry added in v0.20.0

type Win11HistoryEntry struct {
	Object      string `json:"object"`
	SHA256      string `json:"sha256"`
	PublishedAt string `json:"published_at"`
}

Win11HistoryEntry describes one published ISO object.

type Win11LinkInfo added in v0.20.0

type Win11LinkInfo struct {
	URL        string `json:"url"`
	SourceName string `json:"source_name"`
	SHA256     string `json:"sha256"`
}

Win11LinkInfo is written by playwright_win11_iso.py next to the URL file.

func ReadWin11LinkInfo added in v0.20.0

func ReadWin11LinkInfo(arch string) (*Win11LinkInfo, error)

ReadWin11LinkInfo reads the link description of the last resolution for an architecture.

func ResolveWindows11Link(arch string) (*Win11LinkInfo, error)

ResolveWindows11Link asks Microsoft (via Playwright) for the current ISO link. It returns ErrMicrosoftRefused when Microsoft blocks the request.

type Win11Manifest added in v0.20.0

type Win11Manifest struct {
	Schema      int    `json:"schema"`
	Arch        string `json:"arch"`
	Object      string `json:"object"`
	SourceName  string `json:"source_name"`
	Release     string `json:"release"`
	SHA256      string `json:"sha256"`
	Size        int64  `json:"size"`
	Build       string `json:"build"`
	PublishedAt string `json:"published_at"`
	CheckedAt   string `json:"checked_at"`
	// AnnouncedRelease is the newest release the release notes announced at the last successful check.
	// The release-notes trigger fires only once per announcement, see Win11RefreshDue.
	AnnouncedRelease string              `json:"announced_release,omitempty"`
	History          []Win11HistoryEntry `json:"history"`
}

Win11Manifest is the pointer file (win11-<arch>.json) to the current ISO object on the remote cache.

func LoadWin11Manifest added in v0.20.0

func LoadWin11Manifest(file string) (*Win11Manifest, error)

LoadWin11Manifest reads a manifest file. A missing file yields (nil, nil).

func (*Win11Manifest) CheckedTime added in v0.20.0

func (m *Win11Manifest) CheckedTime() time.Time

CheckedTime parses CheckedAt; the zero time is returned when unset or invalid.

func (*Win11Manifest) MarkRefreshDue added in v0.20.0

func (m *Win11Manifest) MarkRefreshDue(now time.Time)

MarkRefreshDue backdates CheckedAt so the next scheduled run contacts Microsoft. Unlike the epoch, the result stays well inside the staleness limit, so a refused first run does not fail.

func (*Win11Manifest) Promote added in v0.20.0

func (m *Win11Manifest) Promote(entry Win11HistoryEntry, sourceName string, size int64, now time.Time) []string

Promote makes entry the current ISO and returns the objects that fell out of the retention window. The object the manifest points to is never part of the returned list.

func (*Win11Manifest) Save added in v0.20.0

func (m *Win11Manifest) Save(file string) error

Save writes the manifest as indented JSON.

Jump to

Keyboard shortcuts

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