config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OfficialCatalogName = "official"
	OfficialCatalogRef  = "ghcr.io/vi-dev/nem-catalog:v1"
)
View Source
const EnvSandbox = "NEM_SANDBOX"

EnvSandbox overrides the config-file `sandbox` setting in both directions: absent or empty defers to config (default enabled); a truthy value forces the sandbox on; a falsy value forces it off. Parsed with strconv.ParseBool.

View Source
const EnvUseOfficialCatalog = "NEM_USE_OFFICIAL_CATALOG"

EnvUseOfficialCatalog controls the official catalog. Unset or empty defers to config; a falsy value (0/false) suppresses it; a truthy value (1/true) uses it. A non-empty non-boolean value is a Load() error. Snapshotted at Config.Load() time.

Variables

View Source
var ErrImplicitOfficial error = ImplicitOfficialError{}

ErrImplicitOfficial is a sentinel for errors.Is checks; use errors.As to extract the name.

View Source
var ErrReservedCatalogName error = ReservedCatalogNameError{}

ErrReservedCatalogName is a sentinel for errors.Is checks; use errors.As to extract the name.

Functions

func IsImplicit added in v0.2.0

func IsImplicit(cfg Config, name string) bool

IsImplicit reports whether name refers to the official catalog, which is implicit (never stored in config.yaml) whenever it is enabled.

func Mutate

func Mutate(fn func(*Config) error) error

func Path

func Path() (string, error)

func RemoveCatalog

func RemoveCatalog(name string) error

func ReorderCatalogs

func ReorderCatalogs(order []string) error

func SandboxEnabled added in v0.6.0

func SandboxEnabled(cfg Config) bool

SandboxEnabled resolves the effective build-sandbox setting: the NEM_SANDBOX snapshot overrides the config file in both directions; the config file overrides the built-in default; the default is enabled.

func Save

func Save(cfg Config) error

func UpsertCatalog

func UpsertCatalog(entry CatalogConfig) (added bool, err error)

func UseOfficialCatalog added in v0.7.0

func UseOfficialCatalog(cfg Config) bool

UseOfficialCatalog resolves whether the official catalog is active: env override > config field > default (true).

Types

type CatalogConfig

type CatalogConfig struct {
	Name     string          `yaml:"name"`
	Type     CatalogType     `yaml:"type"`
	Git      *GitConfig      `yaml:"git,omitempty"`
	LocalDir *LocalDirConfig `yaml:"local-dir,omitempty"`
	OCI      *OCIConfig      `yaml:"oci,omitempty"`
}

func EffectiveCatalogs added in v0.2.0

func EffectiveCatalogs(cfg Config) []CatalogConfig

EffectiveCatalogs returns cfg.Catalogs with the official catalog appended last when it is enabled. The official catalog is lowest precedence, so user catalogs win for any package both define.

func OfficialCatalogConfig added in v0.7.0

func OfficialCatalogConfig() CatalogConfig

OfficialCatalogConfig returns the official catalog. See ADR-025.

func (CatalogConfig) Location

func (r CatalogConfig) Location() string

func (CatalogConfig) Validate

func (r CatalogConfig) Validate() error

type CatalogType

type CatalogType string
const (
	CatalogTypeLocalDir CatalogType = "local-dir"
	CatalogTypeGit      CatalogType = "git"
	CatalogTypeOCI      CatalogType = "oci"
)

type Config

type Config struct {
	Catalogs           []CatalogConfig `yaml:"catalogs"`
	Auth               auth.Config     `yaml:"auth,omitempty"`
	Sandbox            *bool           `yaml:"sandbox,omitempty"`
	UseOfficialCatalog *bool           `yaml:"use-official-catalog,omitempty"`
	// contains filtered or unexported fields
}

func Load

func Load() (Config, error)

func (Config) Catalog

func (c Config) Catalog(name string) (CatalogConfig, int, bool)

func (Config) Validate

func (c Config) Validate() error

type GitConfig

type GitConfig struct {
	Remote string `yaml:"remote"`
	Ref    string `yaml:"ref,omitempty"`
}

type ImplicitOfficialError added in v0.7.0

type ImplicitOfficialError struct {
	Name string
}

ImplicitOfficialError is returned by RemoveCatalog/ReorderCatalogs when the target name refers to the official catalog, which is implicit and never stored in config.yaml.

func (ImplicitOfficialError) Error added in v0.7.0

func (e ImplicitOfficialError) Error() string

func (ImplicitOfficialError) Is added in v0.7.0

func (e ImplicitOfficialError) Is(target error) bool

Is matches any ImplicitOfficialError value, so callers can use errors.Is(err, ErrImplicitOfficial) when they don't need the name.

type LocalDirConfig

type LocalDirConfig struct {
	Path string `yaml:"path"`
}

type OCIConfig added in v0.3.0

type OCIConfig struct {
	Ref string `yaml:"ref"`
}

type ReservedCatalogNameError added in v0.7.0

type ReservedCatalogNameError struct {
	Name string
}

ReservedCatalogNameError is returned when a catalog uses a name reserved for the official catalog.

func (ReservedCatalogNameError) Error added in v0.7.0

func (e ReservedCatalogNameError) Error() string

func (ReservedCatalogNameError) Is added in v0.7.0

func (e ReservedCatalogNameError) Is(target error) bool

Jump to

Keyboard shortcuts

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