Help us shape the future of Go! Take the 2026 Go Developer Survey

managers

package
v1.223.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 ExpandPaths

func ExpandPaths(dir string, patterns []string) ([]string, error)

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.

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.

func All

func All() []Manager

All returns the registered managers sorted by name.

func Get

func Get(name string) (Manager, bool)

Get returns the named file manager.

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 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.

Jump to

Keyboard shortcuts

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