config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCatalogName   = "default"
	DefaultCatalogRemote = "https://github.com/vi-dev/nem-catalog"
	DefaultCatalogRef    = "main"
)
View Source
const EnvNoDefaultCatalog = "NEM_NO_DEFAULT_CATALOG"

EnvNoDefaultCatalog, when set to any non-empty value (typically "1"), suppresses the implicit default catalog. The empty string is treated as unset. Snapshotted at Config.Load() time.

Variables

View Source
var ErrImplicitDefault error = ImplicitDefaultError{}

ErrImplicitDefault 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 implicit default catalog.

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 Save

func Save(cfg Config) error

func UpsertCatalog

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

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"`
}

func DefaultCatalogConfig added in v0.2.0

func DefaultCatalogConfig() CatalogConfig

DefaultCatalogConfig returns the implicit default catalog. See ADR-017.

func EffectiveCatalogs added in v0.2.0

func EffectiveCatalogs(cfg Config) []CatalogConfig

EffectiveCatalogs returns cfg.Catalogs, or the implicit default when cfg is empty and opt-out is unset.

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"
)

type Config

type Config struct {
	Catalogs []CatalogConfig `yaml:"catalogs"`
	Auth     auth.Config     `yaml:"auth,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 ImplicitDefaultError added in v0.2.0

type ImplicitDefaultError struct {
	Name string
}

ImplicitDefaultError is returned by RemoveCatalog/ReorderCatalogs when the target name refers to the implicit default catalog.

func (ImplicitDefaultError) Error added in v0.2.0

func (e ImplicitDefaultError) Error() string

func (ImplicitDefaultError) Is added in v0.2.0

func (e ImplicitDefaultError) Is(target error) bool

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

type LocalDirConfig

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

Jump to

Keyboard shortcuts

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