Documentation
¶
Overview ¶
Package configuration composes alternate configuration formats with built-in component engines.
Index ¶
- func ApplyUnitOverrides(fragments []map[string]any, overrides map[string]any)
- func Attach(ctx context.Context, config *schema.AtmosConfiguration, operation string) error
- func BackendOverrideError(component, stack, setting string) error
- func CheckImportConflicts(manifest string, configs []map[string]any) error
- func CompileManifestSchema(path string) (*jsonschema.Schema, error)
- func ConfiguredDependencyPath(deps, matched []schema.ComponentDependency, path string) string
- func CreateSensitiveTemp(directory string) (*os.File, string, error)
- func ImportComponents(config *schema.AtmosConfiguration, uri string, declaration *schema.StackImport, ...) (map[string]any, bool, error)
- func ImportConflict(component, first, second, where string) error
- func ImportFragment(components map[string]any) map[string]any
- func ImportUnitSources(fragment map[string]any) map[string]string
- func IsRuntimeArtifact(path string) bool
- func MarkBackendOverrides(settings map[string]any, layers ...BackendLayer)
- func MatchDependencies(deps []schema.ComponentDependency, provider bool, resolve func(string) string) []schema.ComponentDependency
- func MergeImportUnitSources(manifest string, units, incoming map[string]string) error
- func OwnsComponent(component map[string]any) bool
- func Register(name string, factory Factory) error
- func RegisterProviderCatalog(catalog ProviderCatalog) error
- func RejectedBackendOverride(settings map[string]any, layers ...BackendLayer) string
- func UnexcludedWatchFiles(root string, all []string, patterns []string) ([]string, error)
- func ValidateDiscoveredManifests(discovered map[string]map[string]any, ...) ([]string, error)
- func WatchExcludes(settings map[string]any) ([]string, error)
- func WatchPaths(config *schema.AtmosConfiguration, settings map[string]any, ...) bool
- func WithWorkdirLock(directory string, fn func() error) error
- func WriteFiles(directory string, files []schema.ComponentConfigurationFile) error
- func WriteFilesWithHandoff(directory string, files []schema.ComponentConfigurationFile, handoff *Handoff) error
- type BackendLayer
- type Factory
- type Handoff
- type ProviderCatalog
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyUnitOverrides ¶
ApplyUnitOverrides attaches a manifest's Terraform `overrides` to the units it imports, like the manifest's own components. Each unit section is copied first, so a provider's cached import result is never changed.
func Attach ¶
Attach creates private state only when a configuration provider is enabled. Sections under `components.terraform` that select no known provider are dropped first (see selectProviders).
func BackendOverrideError ¶
BackendOverrideError describes a component-level backend setting that a component a configuration provider owns may not set. Commands that target the component return it.
func CheckImportConflicts ¶
CheckImportConflicts checks unmerged provider fragments for duplicate unit names. Ordinary YAML and merged stack configurations must not be passed here.
func CompileManifestSchema ¶
func CompileManifestSchema(path string) (*jsonschema.Schema, error)
CompileManifestSchema compiles the Atmos manifest JSON schema at path.
func ConfiguredDependencyPath ¶
func ConfiguredDependencyPath(deps, matched []schema.ComponentDependency, path string) string
ConfiguredDependencyPath reports a matched dependency in its configured spelling. The matched slice must come from MatchDependencies for the same deps.
func CreateSensitiveTemp ¶
CreateSensitiveTemp creates a private file in directory for data that will be renamed into place. The file is restricted before the caller writes to it.
func ImportComponents ¶
func ImportComponents(config *schema.AtmosConfiguration, uri string, declaration *schema.StackImport, staticOnly bool) (map[string]any, bool, error)
ImportComponents resolves a provider import into a manifest fragment for the importing stack. Static inspection rejects provider imports before entering a potentially effectful runtime.
func ImportConflict ¶
ImportConflict reports two units that would become one component of the importing stack.
func ImportFragment ¶
ImportFragment wraps imported units as a stack manifest fragment, so the ordinary import merge adds them to the importing manifest as Terraform components.
func ImportUnitSources ¶
ImportUnitSources extracts identity from a provider import fragment before YAML merging. Callers must not pass ordinary YAML or merged stack configuration.
func IsRuntimeArtifact ¶
IsRuntimeArtifact reserves Terraform state, lock files and workdir metadata. These names mirror the provisioner/workdir contract; importing that package here would create a configuration-loading cycle. Case folding keeps the same protection when a configuration moves between case-sensitive and case-insensitive filesystems.
func MarkBackendOverrides ¶
func MarkBackendOverrides(settings map[string]any, layers ...BackendLayer)
MarkBackendOverrides records on a component's merged settings the backend setting it may not override (see RejectedBackendOverride). The component still compiles, so the rest of the project keeps working, and the commands that target it fail with the rejection. A stale or user-written marker is removed. The configuration map is copied before it changes, because merged settings can share it with a cached provider result.
func MatchDependencies ¶
func MatchDependencies(deps []schema.ComponentDependency, provider bool, resolve func(string) string) []schema.ComponentDependency
MatchDependencies returns the dependencies to compare against a change set. Provider watches are rooted at BasePathAbsolute, and base-path resolution can spell that root differently from the repository root the changed files are joined to: through a symlinked temp dir on macOS (/var vs /private/var) or as an 8.3 short name on Windows (RUNNER~1 vs runneradmin). Two spellings of one directory never match, so provider watches are canonicalized with resolve, which the caller also applies to the change set. YAML dependencies keep exact matching and are returned unchanged.
func MergeImportUnitSources ¶
MergeImportUnitSources accumulates provider provenance across recursive imports.
func OwnsComponent ¶
OwnsComponent reports whether a configuration provider supplies a component section, so callers can avoid attributing it to unrelated YAML files.
func RegisterProviderCatalog ¶
func RegisterProviderCatalog(catalog ProviderCatalog) error
RegisterProviderCatalog sets the catalog that tells provider sections from unrelated mappings under `components.terraform`. It is registered once during host composition.
func RejectedBackendOverride ¶
func RejectedBackendOverride(settings map[string]any, layers ...BackendLayer) string
RejectedBackendOverride returns the component-level backend setting that a component a configuration provider owns may not set, or an empty string: the unit's own backend is its state identity. A component without a provider is unaffected.
func UnexcludedWatchFiles ¶
UnexcludedWatchFiles returns the files that match none of the project-relative patterns.
The project root and a changed file can spell one directory differently, for example through a symlinked temporary directory, so a path that appears outside the root is compared again with symlinks resolved on both sides. A file that is still outside the project, including one on another volume, cannot match a project-relative exclusion and stays watched rather than letting a pattern such as `**` swallow a `../` path. Comparing a relative root with an absolute file is rejected, because it would silently match nothing.
func ValidateDiscoveredManifests ¶
func ValidateDiscoveredManifests(discovered map[string]map[string]any, compile func() (*jsonschema.Schema, error)) ([]string, error)
ValidateDiscoveredManifests checks provider definitions against the same manifest schema as YAML stack manifests, so an invalid discovered field fails validation. The schema is compiled lazily through compile, which lets the caller share its compiled-schema cache; nothing is compiled when no stack was discovered.
func WatchExcludes ¶
WatchExcludes reads and validates the provider's watch_excludes. An absent or empty setting yields no patterns; any other shape is rejected.
func WatchPaths ¶
func WatchPaths(config *schema.AtmosConfiguration, settings map[string]any, deps []schema.ComponentDependency) bool
WatchPaths resolves provider-owned watches against the project root without putting checkout-specific absolute paths into stack comparisons. Existing YAML dependency path semantics remain unchanged. It reports whether the dependencies belong to a provider-discovered component.
func WithWorkdirLock ¶
WithWorkdirLock runs fn while holding the exclusive generated-files lock for the working directory, the same lock every batch write holds. Writers of files that other batches inspect or remove, such as the generated host backend, use it so a check-then-remove in a batch cannot race their write.
func WriteFiles ¶
func WriteFiles(directory string, files []schema.ComponentConfigurationFile) error
WriteFiles materializes evaluated bytes under the provisioned module, without templating.
It also keeps a manifest of what it generated. A file generated by an earlier run that the current run no longer names is removed, so deleting a generate block stops applying it; a file under if_exists = "error" is accepted again when it is the one this host wrote; and the adjacent Terraform lock-file copy is rewritten only when the copy beside the unit changed.
func WriteFilesWithHandoff ¶
func WriteFilesWithHandoff(directory string, files []schema.ComponentConfigurationFile, handoff *Handoff) error
WriteFilesWithHandoff is WriteFiles with a handoff that shares the batch's lock and rollback: it runs only after every destination is valid, and a failure of the handoff or of the batch restores the handoff's paths, so a rejected batch leaves the files it would have replaced in place.
Types ¶
type BackendLayer ¶
BackendLayer is one component-level backend: its type and its settings.
type Factory ¶
type Factory func(context.Context, *schema.AtmosConfiguration, string) (schema.ComponentConfigurationRuntime, error)
Factory constructs an invocation-local session. Registration stores no invocation state.
type Handoff ¶
Handoff is an operation that must run after every destination validates and before the batch writes, such as relinquishing a file the batch replaces. Paths lists the files it may change, so the batch can put them back when it fails.
Validate, when set, runs under the same lock before the handoff and any write, so a check of the existing files cannot be invalidated by another process between the check and the batch.
A batch with a Run func is all-or-nothing: the generated files and the manifest are committed only when the handoff and the whole batch succeed, and any failure rolls back every file the batch wrote.
type ProviderCatalog ¶
type ProviderCatalog func(ctx context.Context, config *schema.AtmosConfiguration) (names map[string]bool, complete bool, err error)
ProviderCatalog lists the configuration providers that the enabled plugin packages export. The boolean result is false when an enabled package's exports cannot be read without installing it.