Documentation
¶
Index ¶
- Constants
- func ActionUses(a *Action) []string
- func IsRemoteCacheMiss(err error) bool
- func IsRemoteRef(ref string) bool
- func PlaybookUses(pb *Playbook) []string
- func ValidateActionYAML(data []byte) error
- func ValidatePlaybookYAML(data []byte) error
- func WriteFileAtomically(path string, data []byte, perm uint32) error
- type Action
- type CacheResolver
- type Chain
- type EmbeddedResolver
- type FetchResult
- type Fetcher
- type GitResolver
- type Input
- type LocalResolver
- type LockEntry
- type Lockfile
- type Playbook
- type RemoteCacheMissError
- type RemoteRef
- type Resolver
- type Task
- type TaskDefaults
Constants ¶
const LockfileName = "preflight.lock"
LockfileName is the project lockfile that pins remote action refs to exact commit SHAs.
Variables ¶
This section is empty.
Functions ¶
func ActionUses ¶
ActionUses returns all distinct uses refs referenced directly by the action's tasks, preserving first-seen order.
func IsRemoteCacheMiss ¶
IsRemoteCacheMiss reports whether err is a remote cache miss.
func IsRemoteRef ¶
IsRemoteRef reports whether ref matches the supported remote action contract.
func PlaybookUses ¶
PlaybookUses returns all distinct uses refs referenced directly by the playbook's tasks, preserving first-seen order.
func ValidateActionYAML ¶
ValidateActionYAML validates an action document against the embedded JSON schema.
func ValidatePlaybookYAML ¶
ValidatePlaybookYAML validates a playbook document against the embedded JSON schema.
Types ¶
type Action ¶
type Action struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Description string `yaml:"description"`
Author string `yaml:"author"`
Defaults TaskDefaults `yaml:"defaults" json:"defaults"`
Inputs map[string]Input `yaml:"inputs"`
Tasks []Task `yaml:"tasks"`
}
Action is the parsed representation of an action.yml file.
func ParseAction ¶
ParseAction parses action YAML bytes into an Action.
type CacheResolver ¶
type CacheResolver struct {
CacheDir string
}
CacheResolver resolves versioned action refs from the local user cache at ~/.preflight/actions/. Refs of the form "github.com/org/name@v1.2" map to <cacheDir>/github.com/org/name@v1.2/action.yml.
func NewCacheResolver ¶
func NewCacheResolver(cacheDir string) *CacheResolver
NewCacheResolver creates a CacheResolver. If cacheDir is empty it defaults to ~/.preflight/actions/.
func (*CacheResolver) Name ¶
func (r *CacheResolver) Name() string
type Chain ¶
type Chain []Resolver
Chain tries each Resolver in order, returning the first non-nil result. If no resolver handles the ref, it returns an error.
func DefaultChain ¶
DefaultChain builds the standard resolver chain:
embedded stdlib → local ./actions/ → user cache → git (stub)
type EmbeddedResolver ¶
EmbeddedResolver resolves stdlib actions from an embedded filesystem. It handles refs with the "preflight/" prefix, mapping them to actions/preflight/<name>/action.yml inside the FS.
func NewEmbeddedResolver ¶
func NewEmbeddedResolver(fsys fs.FS) *EmbeddedResolver
NewEmbeddedResolver creates a resolver backed by the provided embedded FS.
func (*EmbeddedResolver) Name ¶
func (r *EmbeddedResolver) Name() string
Name returns a human-readable identifier for this resolver.
type FetchResult ¶
FetchResult reports the pinned lock entry and parsed action for a fetched remote ref.
type Fetcher ¶
type Fetcher interface {
Fetch(ctx context.Context, ref string) (*FetchResult, error)
}
Fetcher is implemented by resolvers that can acquire remote actions into the local cache.
type GitResolver ¶
type GitResolver struct {
CacheDir string
LockfilePath string
// contains filtered or unexported fields
}
GitResolver fetches action definitions from remote Git repositories. The ref format is "host/org/repo[/path/to/action]@version" or "host/org/repo[/path/to/action]@sha".
func NewGitResolver ¶
func NewGitResolver(cacheDir, lockfilePath string) *GitResolver
NewGitResolver creates a GitResolver that caches fetched actions in cacheDir and consults the project lockfile at lockfilePath.
func (*GitResolver) Fetch ¶
func (r *GitResolver) Fetch(ctx context.Context, ref string) (*FetchResult, error)
Fetch downloads the remote action into the pinned cache and updates the project lockfile.
func (*GitResolver) Name ¶
func (r *GitResolver) Name() string
type Input ¶
type Input struct {
Type string `yaml:"type"` // string, bool, int, path
Required bool `yaml:"required"`
Default any `yaml:"default"`
Description string `yaml:"description"`
}
Input describes a typed input parameter for an action.
type LocalResolver ¶
type LocalResolver struct {
BaseDir string
}
LocalResolver resolves action refs from a local project actions directory. A ref like "myorg/display-config" maps to <BaseDir>/myorg/display-config/action.yml.
Refs that look like remote URLs (contain "://", start with "github.com/", etc.) are not handled by this resolver.
func NewLocalResolver ¶
func NewLocalResolver(baseDir string) *LocalResolver
NewLocalResolver creates a resolver that looks up actions under baseDir.
func (*LocalResolver) Name ¶
func (r *LocalResolver) Name() string
Name returns a human-readable identifier for this resolver.
type LockEntry ¶
type LockEntry struct {
Ref string `json:"ref"`
SHA string `json:"sha"`
Pinned string `json:"pinned"` // original ref before SHA pinning
}
LockEntry records a pinned action reference.
type Lockfile ¶
Lockfile manages the preflight.lock file which pins remote action refs to exact Git SHAs for reproducible builds.
func LoadLockfile ¶
LoadLockfile reads and parses a lockfile from path. If the file does not exist, an empty Lockfile is returned without error.
type Playbook ¶
type Playbook struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Defaults TaskDefaults `yaml:"defaults" json:"defaults"`
Vars map[string]any `yaml:"vars"`
Import []string `yaml:"import"`
Tasks []Task `yaml:"tasks"`
}
Playbook is the parsed representation of a playbook.yml file.
func LoadPlaybookFile ¶
LoadPlaybookFile reads a playbook and recursively merges any imported playbooks depth-first. Imported vars are merged first, then overridden by the importing playbook's vars; imported tasks are prepended in listed order.
func ParsePlaybook ¶
ParsePlaybook parses playbook YAML bytes into a Playbook.
type RemoteCacheMissError ¶
type RemoteCacheMissError struct {
Ref string
}
RemoteCacheMissError reports that a remote action is not available from the current cache and lockfile state.
func (*RemoteCacheMissError) Error ¶
func (e *RemoteCacheMissError) Error() string
type RemoteRef ¶
RemoteRef is a parsed remote action ref of the form host/org/repo[/path/to/action]@rev.
func ParseRemoteRef ¶
ParseRemoteRef parses a remote action ref into repository, optional action path, and revision components.
func (*RemoteRef) CloneURLs ¶
CloneURLs returns candidate HTTPS clone URLs for the remote repository.
func (*RemoteRef) IsPinned ¶
IsPinned reports whether the revision already looks like a Git commit SHA.
type Resolver ¶
type Resolver interface {
// Resolve returns the Action for the given ref, or (nil, nil) if this
// resolver does not handle the ref.
Resolve(ctx context.Context, ref string) (*Action, error)
// Name returns a human-readable name for this resolver (for error messages).
Name() string
}
Resolver resolves an action ref to an Action definition.
type Task ¶
type Task struct {
Name string `yaml:"name"`
ID string `yaml:"id"`
Uses string `yaml:"uses"`
With map[string]any `yaml:"with"`
Become map[string]any `yaml:"become" json:"become,omitempty"`
ModuleName string `yaml:"module"`
ModuleParams map[string]any `yaml:"params"`
Module string `yaml:"-"` // canonical module name
Params map[string]any `yaml:"-"` // canonical module params
When string `yaml:"when"`
DependsOn []string `yaml:"depends_on"`
IgnoreErrors bool `yaml:"ignore_errors"`
Tags []string `yaml:"tags"`
// InlineModules stores known inline module definitions by YAML module name.
InlineModules map[string]map[string]any `yaml:"-"`
}
Task is a single step inside an action or playbook.
Module and Params are the canonical internal representation used after parsing/normalization. InlineModules preserves decode-time sugar for known inline module YAML keys.
func (*Task) ResolveModule ¶
ResolveModule canonicalizes a task into its internal module+params form. Returns an error if more than one inline module field is set, or if both "uses" and a concrete module are set.
type TaskDefaults ¶
TaskDefaults describes execution defaults inherited by tasks.