config

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 17 Imported by: ? modules, 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

Overview

Package config loads and validates ghalet settings and storage policy.

Index

Constants

View Source
const DefaultRunnerVersion = "2.338.0"
View Source
const (
	SystemConfigPath = "/etc/ghalet/config.yaml"
)

Variables

This section is empty.

Functions

func CheckManagedPaths

func CheckManagedPaths(managedPath, configPath string, reserved ...string) error

CheckManagedPaths rejects collisions with static configuration and other persistence files, including aliases through a final configuration symlink.

func ManagedPath

func ManagedPath(configPath, selected string) (string, error)

ManagedPath resolves an explicit path relative to the static configuration. Nonstandard configurations get isolated files in the process's state directory.

func ResolvePath

func ResolvePath(path string) (string, error)

ResolvePath returns the lexical absolute configuration path, preserving symlinks.

func RunnerGroupName

func RunnerGroupName(name string) string

RunnerGroupName resolves an omitted group to GitHub's default runner group.

func ScopeURL

func ScopeURL(raw string) (*url.URL, error)

ScopeURL validates and parses a GitHub organization or repository URL.

func StateDirectory

func StateDirectory() (string, error)

StateDirectory returns the persistent application directory used by this process, resolving symlinks in its trusted storage base.

func TargetKey

func TargetKey(scope, group, scaleSet string) (string, error)

TargetKey returns a filesystem-safe identity for a scope/group/scale set registration.

func ValidTargetID

func ValidTargetID(id string) bool

ValidTargetID reports whether an ID is safe for a target's managed directory.

func WriteManaged

func WriteManaged(path string, before, after []byte) error

WriteManaged commits a prepared snapshot without overwriting another writer.

func WriteManagedFile added in v0.2.0

func WriteManagedFile(path string, data []byte) error

WriteManagedFile publishes a managed document owned by its storage directory's owner when an administrator writes it on behalf of the service account. Callers must coordinate writers and validate the prepared document first.

Types

type CapacityConfig

type CapacityConfig struct {
	MaxRunners int `yaml:"maxRunners"`
}

type Config

type Config struct {
	ManagedFile string         `yaml:"managedFile"`
	Defaults    DefaultsConfig `yaml:"defaults"`
	Capacity    CapacityConfig `yaml:"capacity"`
	Targets     []Target       `yaml:"targets"`
	Runner      RunnerConfig   `yaml:"runner"`
	Logs        LogsConfig     `yaml:"logs"`
	Path        string         `yaml:"-"`
	// contains filtered or unexported fields
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

func ParseConfig

func ParseConfig(path string, content []byte) (*Config, error)

ParseConfig resolves and validates configuration bytes without writing a file.

func ParseConfigWithManaged added in v0.2.0

func ParseConfigWithManaged(path string, content []byte, managed *Managed) (*Config, error)

ParseConfigWithManaged validates a proposed static and managed configuration.

func (*Config) RetainSecretEnvironment

func (c *Config) RetainSecretEnvironment(previous *Config)

RetainSecretEnvironment preserves credential variable history across applies.

func (*Config) SecretEnv

func (c *Config) SecretEnv(name string) bool

SecretEnv reports management secrets, including previously configured names.

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) ValidateEnvironment

func (c *Config) ValidateEnvironment() error

ValidateEnvironment checks runner overrides against identity and secret policy.

type Credential

type Credential struct {
	Type           string `yaml:"type"`
	Hostname       string `yaml:"hostname,omitempty"`
	TokenEnv       string `yaml:"tokenEnv,omitempty"`
	TokenFile      string `yaml:"tokenFile,omitempty"`
	ClientID       string `yaml:"clientId,omitempty"`
	PrivateKeyFile string `yaml:"privateKeyFile,omitempty"`
	InstallationID int64  `yaml:"installationId,omitempty"`
}

func (*Credential) UnmarshalYAML

func (c *Credential) UnmarshalYAML(unmarshal func(any) error) error

type DefaultsConfig

type DefaultsConfig struct {
	Credential *Credential `yaml:"credential"`
}

type Duration

type Duration time.Duration

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(any) error) error

type Editor

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

Editor updates ghalet configuration mappings without discarding their order or comments. Aliases are expanded so replacing defaults cannot change explicit target credentials that referred to the old defaults.

func NewEditor

func NewEditor(data []byte, schema any) (*Editor, error)

NewEditor reads one configuration mapping. When schema is non-nil, it also decodes known fields into schema before allowing edits.

func (*Editor) AppendTarget

func (editor *Editor) AppendTarget(scope, group, scaleSet string) error

AppendTarget adds a target that inherits the configured credential.

func (*Editor) Marshal

func (editor *Editor) Marshal() ([]byte, error)

Marshal returns the edited configuration with its comments and mapping order.

func (*Editor) RemoveDefaultCredential added in v0.2.0

func (editor *Editor) RemoveDefaultCredential()

RemoveDefaultCredential allows an explicitly selected managed default to apply.

func (*Editor) SetDefaultCredential

func (editor *Editor) SetDefaultCredential(credentialType, clientID, path string, installationID int64)

SetDefaultCredential replaces defaults while leaving explicit targets intact.

func (*Editor) SetTargetApp

func (editor *Editor) SetTargetApp(id, clientID, keyPath string, installationID int64) error

SetTargetApp replaces a target's credentials and installation.

type LogsConfig

type LogsConfig struct {
	Preserve  bool     `yaml:"preserve"`
	Retention Duration `yaml:"retention"`
	Root      string   `yaml:"root"`
}

type Managed

type Managed struct {
	Defaults DefaultsConfig  `yaml:"defaults,omitempty"`
	Targets  []ManagedTarget `yaml:"targets,omitempty"`
}

Managed contains persistent setup information, not runnable target definitions or secret values. Targets become active only through the static configuration.

func ParseManaged

func ParseManaged(data []byte) (*Managed, error)

func ReadManaged

func ReadManaged(path string) (*Managed, []byte, error)

ReadManaged returns an empty document when the file does not exist.

func (*Managed) Marshal

func (managed *Managed) Marshal() ([]byte, error)

func (*Managed) SetTarget

func (managed *Managed) SetTarget(target ManagedTarget)

type ManagedTarget

type ManagedTarget struct {
	Scope        string     `yaml:"scope"`
	RunnerGroup  string     `yaml:"runnerGroup,omitempty"`
	ScaleSetName string     `yaml:"scaleSet"`
	Credential   Credential `yaml:"credential"`
}

type RunnerConfig

type RunnerConfig struct {
	Version        string            `yaml:"version"`
	User           string            `yaml:"user"`
	StartupTimeout Duration          `yaml:"startupTimeout"`
	DrainTimeout   Duration          `yaml:"drainTimeout"`
	WorkRoot       string            `yaml:"-"`
	CacheRoot      string            `yaml:"-"`
	Env            map[string]string `yaml:"env"`
}

type ScalingConfig

type ScalingConfig struct {
	MinRunners int `yaml:"minRunners"`
	MaxRunners int `yaml:"maxRunners"`
}

type Target

type Target struct {
	ID           string        `yaml:"-"` // Derived from the registration, never configured.
	URL          string        `yaml:"scope"`
	Credential   Credential    `yaml:"credential"`
	RunnerGroup  string        `yaml:"runnerGroup"`
	ScaleSetName string        `yaml:"scaleSet"`
	Scaling      ScalingConfig `yaml:"scaling"`
	// contains filtered or unexported fields
}

func (*Target) UnmarshalYAML

func (t *Target) UnmarshalYAML(unmarshal func(any) error) error

Jump to

Keyboard shortcuts

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