label

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package label provides dynamic label parsing for GitHub Actions runner specifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Has

func Has(labels []string) bool

Has returns true if any of the provided labels start with "cihub-". Used to check if a job's requested labels include cihub labels.

Types

type Label

type Label struct {
	Arch core.Arch `json:"arch"` // CPU architecture (amd64, arm64), defaults to amd64
	RAM  int64     `json:"ram"`  // RAM in megabytes
	CPU  int64     `json:"cpu"`  // CPU cores allocated
}

Label represents resource specifications for runners parsed from a label string. Labels are requested by GitHub Actions jobs via runs-on field.

Format for dynamic labels: cihub-<cpu>cpu-<ram>(mb|gb)[-<arch>] Examples:

  • cihub-2cpu-4gb → 2 CPU, 4096 MB RAM, amd64
  • cihub-4cpu-8gb-arm64 → 4 CPU, 8192 MB RAM, arm64
  • cihub-2cpu-2048mb → 2 CPU, 2048 MB RAM, amd64

func Parse

func Parse(s string) (*Label, error)

Parse parses a label string and returns a Label struct. Format: cihub-<cpu>cpu-<ram>(mb|gb)[-<arch>] Examples:

  • cihub-2cpu-4gb
  • cihub-4cpu-8gb-arm64
  • cihub-2cpu-2048mb-amd64

Returns nil if the label doesn't match the cihub- pattern. Returns error if the label matches the pattern but is invalid.

func Resolve

func Resolve(labels []string) (*Label, error)

Resolve finds the first cihub- prefixed label from the job labels and parses it. Returns nil if no cihub- label is found or if parsing fails. If parsing fails for a cihub- label, returns an error.

func (*Label) Validate

func (l *Label) Validate() error

Validate validates the label configuration. Returns error if CPU <= 0, RAM <= 0, or Arch is not amd64 or arm64.

Jump to

Keyboard shortcuts

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