config

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigDir = "~/.config/tomei"
	DefaultDataDir   = "~/.local/share/tomei"
	DefaultBinDir    = "~/.local/bin"
	DefaultEnvDir    = "~/.config/tomei"
)

Default path constants

View Source
const (
	// ConfigFileName is the name of the tomei config file that should be ignored when loading manifests.
	ConfigFileName = "config.cue"

	// TomeiModulePath is the CUE module path for the tomei module.
	TomeiModulePath = "tomei.terassyi.net@v0"

	// CUELanguageVersion is the CUE language version used by the tomei module.
	CUELanguageVersion = "v0.9.0"

	// EnvCUERegistry is the environment variable name for the CUE registry.
	EnvCUERegistry = "CUE_REGISTRY"

	// DefaultCUERegistry is the built-in CUE_REGISTRY mapping for tomei modules.
	// When CUE_REGISTRY is not set, this default is used to resolve
	// tomei.terassyi.net imports from the OCI registry on ghcr.io.
	DefaultCUERegistry = "tomei.terassyi.net=ghcr.io/terassyi"
)

Variables

This section is empty.

Functions

func CUERegistryOrDefault

func CUERegistryOrDefault() string

CUERegistryOrDefault returns the CUE_REGISTRY environment variable value, or DefaultCUERegistry if not set.

Types

type Arch

type Arch string

Arch represents the CPU architecture.

const (
	ArchAMD64 Arch = "amd64"
	ArchARM64 Arch = "arm64"
)

type Config

type Config struct {
	DataDir string `json:"dataDir"`
	BinDir  string `json:"binDir"`
	EnvDir  string `json:"envDir"`
}

Config represents tomei configuration.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration.

func LoadConfig

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

LoadConfig loads configuration from the config directory. Returns default config if config.cue doesn't exist or has no config block.

func (*Config) ToCue

func (c *Config) ToCue() ([]byte, error)

ToCue generates CUE content from Config.

type Env

type Env struct {
	OS       OS   `json:"os"`
	Arch     Arch `json:"arch"`
	Headless bool `json:"headless"`
}

Env represents environment variables injected into CUE configuration.

func DetectEnv

func DetectEnv() *Env

DetectEnv detects the current environment.

type Loader

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

Loader loads and parses CUE configuration files.

func NewLoader

func NewLoader(env *Env, opts ...LoaderOption) *Loader

NewLoader creates a new Loader with the given environment and options.

func (*Loader) EvalDir

func (l *Loader) EvalDir(dir string) (cue.Value, error)

EvalDir evaluates CUE files in a directory and returns the unified cue.Value without parsing into resource types. Used by tomei cue eval/export.

func (*Loader) EvalFile

func (l *Loader) EvalFile(path string) (cue.Value, error)

EvalFile evaluates a single CUE file and returns the cue.Value without parsing into resource types. Used by tomei cue eval/export.

func (*Loader) EvalPaths

func (l *Loader) EvalPaths(paths []string) ([]cue.Value, error)

EvalPaths evaluates multiple files or directories and returns a slice of cue.Values. Each path produces one cue.Value. Used by tomei cue eval/export.

func (*Loader) Load

func (l *Loader) Load(dir string) ([]resource.Resource, error)

Load loads CUE configuration from the given directory. config.cue files are excluded from loading as they contain tomei configuration, not manifests.

func (*Loader) LoadFile

func (l *Loader) LoadFile(path string) ([]resource.Resource, error)

LoadFile loads a single CUE file. If the file is config.cue, it is skipped and returns empty resources. Files with a package declaration use load.Instances() so that import statements are resolved. Files without a package declaration use CompileString() (import is not available without a package).

func (*Loader) LoadPaths

func (l *Loader) LoadPaths(paths []string) ([]resource.Resource, error)

LoadPaths loads resources from multiple files or directories.

type LoaderOption

type LoaderOption func(*Loader)

LoaderOption configures a Loader.

func WithVerifier

func WithVerifier(v verify.Verifier) LoaderOption

WithVerifier sets the cosign signature verifier for CUE module dependencies. When set, the Loader verifies first-party module signatures before CUE evaluation.

type OS

type OS string

OS represents the operating system.

const (
	OSLinux  OS = "linux"
	OSDarwin OS = "darwin"
)

Jump to

Keyboard shortcuts

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