machine

package
v1.35.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: CC0-1.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMachineID

func GetMachineID() string

GetMachineID returns a deterministic, unique machine identifier. The ID is stable across hostname changes and other system configuration changes. It uses platform-specific stable identifiers:

  • macOS: IOPlatformUUID (hardware UUID)
  • Linux: /etc/machine-id or /var/lib/dbus/machine-id
  • Windows: Registry MachineGuid

The raw identifier is hashed with SHA-256 and truncated to 16 characters for a more user-friendly format while maintaining uniqueness.

func ResetMachineID

func ResetMachineID()

ResetMachineID clears the cached machine ID. This is primarily used for testing.

func SetMachineID

func SetMachineID(id string)

SetMachineID overrides the detected machine ID. This is primarily used for testing.

Types

type Machines

type Machines struct {
	// Only specifies a list of machine IDs or aliases where the configuration should apply.
	Only *[]string `json:"only"   yaml:"only"`
	// Except specifies a list of machine IDs or aliases where the configuration should not apply.
	Except *[]string `json:"except" yaml:"except"`
}

Machines defines which machines a configuration applies to.

func (*Machines) GetShouldRunOnMachine

func (m *Machines) GetShouldRunOnMachine(machineID string, aliases map[string]string) bool

GetShouldRunOnMachine determines if a configuration should run on the current machine based on the Only and Except fields of the Machines struct. The aliases parameter is a map of friendly names to machine IDs. When checking, aliases are resolved first, falling back to treating the value as a literal machine ID.

Jump to

Keyboard shortcuts

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