config

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 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 decodes, validates, and interprets the `artifacts` section of atmos.yaml.

It is separate from pkg/artifact so that the domain package stays free of configuration policy, while pkg/config (the loader) and the artifact service share one implementation of:

  • strict decoding of the raw section into schema.ArtifactConfig, including rejecting unquoted numeric permissions that YAML would silently turn into the wrong octal value;
  • whole-configuration validation (kinds, per-kind options, packaging, permissions, catalogs, identities, labels, verification policy, and delegated lock chains);
  • the effective verification policy model, where a global requirement can be strengthened but never weakened by a repository and both trust sets must be satisfied;
  • anchoring relative local paths to the configuration file that declared them.

Validation performs no network access, resolves no credentials, and creates no directories. An `identity` is only checked for shape (and, when the caller supplies a lookup, existence); it is resolved lazily by the operation that needs credentials.

Repository kinds

Kind names are checked against artifact.RepositoryRegistry, which returns a registered backend's descriptor when one exists and otherwise the documented static set of V1 kinds (local/dir, local/archive, aws/s3, oci/registry, oci/layout). Validation therefore works before backend packages register, and a backend that registers a kind refines the descriptor rather than changing the accepted names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnchorPath

func AnchorPath(origin schema.ArtifactConfigOrigin, p string) (string, error)

AnchorPath returns the absolute, cleaned form of p. An absolute path is only cleaned. A relative path resolves against the directory of the configuration file that declared it, so the result does not depend on the working directory or on which file was merged last.

A relative path declared by a remote import cannot be anchored: its local copy lives in an ephemeral download directory that must never become a write root. A relative path with no known declaring file is likewise rejected. In both cases the caller must provide an absolute path or override the value in a locally declared configuration file.

func CombinePolicy

func CombinePolicy(global, repo *schema.ArtifactVerificationConfig) artifact.VerificationPolicy

CombinePolicy combines a global and a repository policy level. Either may be nil.

func Decode

func Decode(raw map[string]any) (schema.ArtifactConfig, error)

Decode strictly decodes a raw `artifacts` section (as parsed from YAML, with original key spelling) into the schema type. Unknown fields, mistyped values, and non-string permissions are errors, so `permissions: 0600` (which YAML reads as the integer 384) never silently becomes the wrong mode. A nil or empty section decodes to the zero value.

func EffectivePolicy

func EffectivePolicy(cfg *schema.ArtifactConfig, alias string) (artifact.VerificationPolicy, error)

EffectivePolicy returns the verification policy that applies to a repository.

A global requirement can be strengthened but never weakened: RequireSignature is true when either level requires it. Within one trust set any configured signer satisfies it; when both the global and the repository define trust (identities or keys), the policy carries two trust sets and both must be satisfied, so a repository can narrow trust but never widen it. The global trust set comes first.

func NewOrigin

func NewOrigin(file string, remote bool) schema.ArtifactConfigOrigin

NewOrigin builds the origin of a value declared in file. Remote marks a downloaded import whose local path is ephemeral.

func Validate

func Validate(cfg *schema.ArtifactConfig, opts ...Option) error

Validate validates a whole artifact configuration with a default Validator.

Types

type LockPlan

type LockPlan struct {
	// Provider is the alias of the repository that provides the lock. It is the repository itself
	// unless locking is delegated.
	Provider string

	// Required is the minimum scope mutations need.
	Required artifact.LockScope

	// Chain lists the aliases visited from the repository to the provider, in order.
	Chain []string
}

LockPlan is the resolved lock coordination of one repository.

func ResolveLockPlan

func ResolveLockPlan(cfg *schema.ArtifactConfig, alias string) (LockPlan, error)

ResolveLockPlan follows `locking.repository` delegation from alias to the repository that provides the lock and reports the required scope. It fails on an unknown delegate, on a cycle, and on an invalid scope. It does not check the provider's capability; Validator.Validate does.

type Option

type Option func(*Validator)

Option configures a Validator.

func WithIdentityLookup

func WithIdentityLookup(exists func(name string) bool) Option

WithIdentityLookup also checks that each referenced identity exists. Without it only the shape of the identity name is checked: identities are resolved lazily and may be provisioned later.

func WithRegistry

func WithRegistry(registry *artifact.RepositoryRegistry) Option

WithRegistry validates kinds against a specific registry instead of the process-wide one.

type Validator

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

Validator validates artifact configuration. The zero value is not usable; use NewValidator.

func NewValidator

func NewValidator(opts ...Option) *Validator

NewValidator returns a Validator.

func (*Validator) Validate

func (v *Validator) Validate(cfg *schema.ArtifactConfig) error

Validate checks the global verification policy and every repository, returning all problems joined in a deterministic order. Every error wraps errUtils.ErrArtifactConfigInvalid. It performs no network access, credential resolution, or directory creation.

func (*Validator) ValidateRepository

func (v *Validator) ValidateRepository(cfg *schema.ArtifactConfig, alias string) error

ValidateRepository validates one repository in the context of the whole configuration, which the lock delegation and verification checks need.

Jump to

Keyboard shortcuts

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