Documentation
¶
Overview ¶
Package managers defines the file-manager registry for the Atmos Version Tracker: pluggable scanners/rewriters that keep project files (GitHub Actions workflows, marker-annotated files, rendered templates) in sync with the locked versions. Managers plan pure in-memory changes; shared drivers apply them or fail on drift for CI.
Index ¶
- Variables
- func Apply(changes []PlannedChange) error
- func Check(changes []PlannedChange) error
- func DuplicatePath(paths []string) string
- func ExpandPaths(dir string, patterns []string) ([]string, error)
- func Register(m Manager)
- func RenderValueFormat(formatStr string, ref manager.VersionRef, delims []string) (string, error)
- func TemplateDelimiters(atmosConfig *schema.AtmosConfiguration) []string
- type FileChange
- type Input
- type Manager
- type PlannedChange
- type RenderFunc
- type RunOptions
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDrift is returned by Check when managed files differ from the lock. ErrDrift = errUtils.ErrVersionFilesDrift // ErrUnknownManager is returned for a file rule naming an unregistered manager. ErrUnknownManager = errUtils.ErrUnknownVersionFileManager // ErrDuplicateManager is returned when two managers register the same name. ErrDuplicateManager = errUtils.ErrDuplicateVersionFileManager )
Functions ¶
func Apply ¶
func Apply(changes []PlannedChange) error
Apply writes the planned changes to disk, preserving existing file modes.
func Check ¶
func Check(changes []PlannedChange) error
Check fails with ErrDrift when any planned change would modify a file, listing the stale paths for CI output.
func DuplicatePath ¶ added in v1.229.0
DuplicatePath returns the first path that appears more than once in paths, or "" if every path is unique. Shared by every file manager whose set entries carry a Path (json, yaml), so "two set entries can't target the same field" behavior stays consistent across manager types.
func ExpandPaths ¶
ExpandPaths resolves glob patterns relative to dir into matching file paths.
func Register ¶
func Register(m Manager)
Register adds a file manager. It panics on a duplicate name: registration happens in init() and a duplicate is a programming error.
func RenderValueFormat ¶ added in v1.229.0
RenderValueFormat renders a set entry's optional Format template against the resolved version ref, exposing .Version, .Digest, and .Pin. Shared by every file manager whose set entries support an optional value-reshaping Format field (json, yaml) so the template dialect and available functions stay identical across manager types. The delims argument is the raw `templates.settings.delimiters` value; the standard Go delimiters apply when it is unset or malformed.
func TemplateDelimiters ¶ added in v1.229.0
func TemplateDelimiters(atmosConfig *schema.AtmosConfiguration) []string
TemplateDelimiters returns the raw `templates.settings.delimiters` value from atmosConfig, or nil when the config is absent. Managers pass it through to RenderValueFormat so a project's custom delimiters apply to set-entry Format templates the same way they apply everywhere else.
Types ¶
type FileChange ¶
type FileChange struct {
// Path is the file to write (relative to Input.Dir or absolute).
Path string
// Old is the current content (nil when the file does not exist).
Old []byte
// New is the desired content.
New []byte
}
FileChange is one planned file modification.
type Input ¶
type Input struct {
// Config is the Atmos configuration.
Config *schema.AtmosConfiguration
// Track is the effective version track.
Track string
// Entries are the track's effective entries (policy applied).
Entries map[string]manager.EffectiveEntry
// Refs are the locked version references by entry name.
Refs map[string]manager.VersionRef
// Dir is the root directory globs are resolved from.
Dir string
// Paths are the glob patterns to scan (the manager's defaults when empty).
Paths []string
// Options carries manager-specific settings from the file rule.
Options map[string]any
// Render is the template engine (used by the template manager).
Render RenderFunc
}
Input is everything a file manager needs to plan its changes.
type Manager ¶
type Manager interface {
// Name returns the manager's registry name.
Name() string
// DefaultPaths returns the glob patterns scanned when no file rule
// configures paths (empty means the manager only runs when configured).
DefaultPaths() []string
// Plan returns the file changes needed to match the locked versions.
Plan(ctx context.Context, in *Input) ([]FileChange, error)
}
Manager plans version updates for a class of project files. Plan must be pure: it never writes; the shared Apply/Check drivers act on its output.
type PlannedChange ¶
type PlannedChange struct {
Manager string
FileChange
}
PlannedChange associates a change with the manager that planned it.
func Plan ¶
func Plan(ctx context.Context, opts *RunOptions) ([]PlannedChange, error)
Plan runs the configured file rules (or every registered manager's default paths when version.files is empty) and returns all planned changes.
type RenderFunc ¶
type RenderFunc = manager.RenderFunc
RenderFunc renders template content with the given data. The command layer injects the Atmos template engine so this package never depends on internal/exec.
type RunOptions ¶
type RunOptions struct {
// Config is the Atmos configuration.
Config *schema.AtmosConfiguration
// Track selects the version track ("" means the configured default).
Track string
// Dir is the root directory ("" means the current directory).
Dir string
// Only limits the run to the named managers (empty means all).
Only []string
// Render is the template engine for the template manager.
Render RenderFunc
}
RunOptions configures a plan across the configured file rules.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package githubactions implements the github-actions file manager: it scans workflow files for `uses:` action references, matches them against managed version entries by owner/repo package, and rewrites the ref from the lock.
|
Package githubactions implements the github-actions file manager: it scans workflow files for `uses:` action references, matches them against managed version entries by owner/repo package, and rewrites the ref from the lock. |
|
Package json implements the json file manager: sjson/gjson-based in-place field writes on plain JSON files (package manifests, plugin listings, and similar), configured via `options.set: [{path, from, format}]`.
|
Package json implements the json file manager: sjson/gjson-based in-place field writes on plain JSON files (package manifests, plugin listings, and similar), configured via `options.set: [{path, from, format}]`. |
|
Package marker implements the marker file manager: the Renovate regex-manager equivalent for arbitrary text files.
|
Package marker implements the marker file manager: the Renovate regex-manager equivalent for arbitrary text files. |
|
Package template implements the template file manager: *.tmpl files are the human-edited source of truth and render to a sibling file with the .tmpl suffix stripped, using the .version context resolved from the lock.
|
Package template implements the template file manager: *.tmpl files are the human-edited source of truth and render to a sibling file with the .tmpl suffix stripped, using the .version context resolved from the lock. |
|
Package yaml implements the yaml file manager: in-place field writes on existing YAML files (values files, extra config, and similar), configured via `options.set: [{path, from, format}]`.
|
Package yaml implements the yaml file manager: in-place field writes on existing YAML files (values files, extra config, and similar), configured via `options.set: [{path, from, format}]`. |