Documentation
¶
Index ¶
- Constants
- Variables
- func IsImplicit(cfg Config, name string) bool
- func Mutate(fn func(*Config) error) error
- func Path() (string, error)
- func RemoveCatalog(name string) error
- func ReorderCatalogs(order []string) error
- func SandboxEnabled(cfg Config) bool
- func Save(cfg Config) error
- func UpsertCatalog(entry CatalogConfig) (added bool, err error)
- func UseDefaultCatalog(cfg Config) bool
- type CatalogConfig
- type CatalogType
- type Config
- type GitConfig
- type ImplicitDefaultError
- type LocalDirConfig
- type OCIConfig
Constants ¶
const ( DefaultCatalogName = "default" DefaultCatalogRef = "ghcr.io/vi-dev/nem-catalog:v1" )
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.
const EnvUseDefaultCatalog = "NEM_USE_DEFAULT_CATALOG"
EnvUseDefaultCatalog controls the implicit default 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 ¶
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
IsImplicit reports whether name refers to the implicit default catalog.
func RemoveCatalog ¶
func ReorderCatalogs ¶
func SandboxEnabled ¶ added in v0.6.0
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 UpsertCatalog ¶
func UpsertCatalog(entry CatalogConfig) (added bool, err error)
func UseDefaultCatalog ¶ added in v0.6.0
UseDefaultCatalog resolves whether the implicit default 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 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 the default is enabled.
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"`
UseDefaultCatalog *bool `yaml:"use-default-catalog,omitempty"`
// contains filtered or unexported fields
}
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"`
}