planfile

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: 14 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

Index

Constants

View Source
const (
	// PlanFilename is the well-known name for the plan file within a bundle.
	PlanFilename = "plan.tfplan"

	// LockFilename is the well-known name for the lock file within a bundle.
	LockFilename = ".terraform.lock.hcl"

	// BindingFilename is the well-known name for the plan record within a bundle. Components
	// whose configuration provider owns their saved plans (for example Terragrunt units) keep a
	// record beside the plan file that proves what was reviewed; without it another runner cannot
	// apply the plan. Components that have no record upload nothing under this name.
	BindingFilename = PlanFilename + ".atmos.json"

	// StoredPlanPrefix is the prefix used for stored planfiles during plan verification.
	// When --verify-plan is set in CI mode, the downloaded planfile gets this prefix
	// so terraform can generate a fresh plan at the canonical path for comparison.
	StoredPlanPrefix = "stored."
)

Variables

This section is empty.

Functions

func BindingPath

func BindingPath(planfilePath string) string

BindingPath returns where the plan record of a plan file is kept on disk.

func IsPlanRequired added in v1.222.0

func IsPlanRequired(atmosConfig *schema.AtmosConfiguration, ciEnabled bool, cliOverride schema.PlanfileVerifyMode) bool

IsPlanRequired reports whether `atmos terraform deploy` must find a stored planfile to verify against (as opposed to ResolveVerifyMode, which governs the drift comparison once a stored plan exists). Resolution:

  • When verification resolves to off, nothing is downloaded or verified, so a stored plan is never required (this also short-circuits an explicit `required: true` paired with `--verify-plan=false`).
  • An explicit components.terraform.planfiles.required wins.
  • Unset: required tracks verify strictness — true only when verification resolves to fail (e.g. under CI with storage configured). This makes a fail-by-default deploy fail loudly on a missing plan instead of silently applying an unverified fresh plan; local deploys (no CI, no storage) resolve to off and are never required.

The cliOverride is empty when neither flag was set.

func IsSourceReference

func IsSourceReference(key string) bool

IsSourceReference identifies internal source-tree references rather than plans. The tree- prefix cannot collide with a hexadecimal commit SHA.

func ResolveVerifyMode added in v1.222.0

func ResolveVerifyMode(atmosConfig *schema.AtmosConfiguration, ciEnabled bool, cliOverride schema.PlanfileVerifyMode) schema.PlanfileVerifyMode

ResolveVerifyMode resolves the effective planfile drift-verification mode for `atmos terraform deploy`, applying precedence:

explicit CLI override (--verify-plan / --verify-plan=false)
  > config (components.terraform.planfiles.verify)
  > default: fail when CI is enabled and planfile storage is configured, else off.

cliOverride is empty when neither flag was set.

func StorageConfigured added in v1.222.0

func StorageConfigured(pf *schema.PlanfilesConfig) bool

StorageConfigured reports whether explicit planfile storage is configured (via a default store, a priority list, or named stores). When no planfile configuration exists, upload/download/verify are skipped.

func WritePlanfileResults

func WritePlanfileResults(results []FileResult, planfilePath string) error

WritePlanfileResults writes downloaded planfile results to disk. It maps PlanFilename to planfilePath, BindingFilename to the plan record beside it, and LockFilename to the same directory. Parent directories are created as needed. Unknown filenames are skipped.

func WritePlanfileResultsForVerification

func WritePlanfileResultsForVerification(results []FileResult, storedPlanPath, canonicalPlanPath string) error

WritePlanfileResultsForVerification writes downloaded planfile results for plan verification. The plan file is written to storedPlanPath (with stored prefix), while the lock file is written relative to canonicalPlanPath (the canonical location where terraform expects it). This separation allows terraform to generate a fresh plan at the canonical path for comparison.

Types

type FileEntry

type FileEntry = artifact.FileEntry

Type aliases to align planfile types with artifact types.

func OpenBinding

func OpenBinding(planfilePath string) (FileEntry, io.Closer, error)

OpenBinding opens the plan record beside a plan file for upload. It returns a nil closer when there is none, which is the normal case for components that do not keep one. A record that exists but cannot be opened is an error: uploading the plan without it would leave a fresh runner unable to apply it. The caller closes the returned file.

type FileResult

type FileResult = artifact.FileResult

Type aliases to align planfile types with artifact types.

type KeyContext

type KeyContext struct {
	Stack         string
	Component     string
	ComponentPath string
	SHA           string
	BaseSHA       string
	Branch        string
	PRNumber      int
	RunID         string
}

KeyContext contains the context for generating a planfile key.

type KeyPattern

type KeyPattern struct {
	Pattern string
}

KeyPattern holds the pattern configuration for generating planfile keys.

func DefaultKeyPattern

func DefaultKeyPattern() KeyPattern

DefaultKeyPattern returns the default planfile key pattern.

func (KeyPattern) GenerateKey

func (p KeyPattern) GenerateKey(ctx *KeyContext) (string, error)

GenerateKey generates a planfile key from the context using the pattern. Returns an error if required fields (Stack, Component, SHA) are empty when they are used in the pattern.

type Metadata

type Metadata struct {
	artifact.Metadata

	// PlanSummary contains a human-readable summary of the plan.
	PlanSummary string `json:"plan_summary,omitempty"`

	// HasChanges indicates whether the plan has changes.
	HasChanges bool `json:"has_changes"`

	// Additions is the number of resources to add.
	Additions int `json:"additions"`

	// Changes is the number of resources to change.
	Changes int `json:"changes"`

	// Destructions is the number of resources to destroy.
	Destructions int `json:"destructions"`

	// TerraformVersion is the version of Terraform used.
	TerraformVersion string `json:"terraform_version,omitempty"`

	// TerraformTool is the Terraform tool used (e.g., "terraform", "tofu").
	TerraformTool string `json:"terraform_tool,omitempty"`
}

Metadata contains metadata about a stored planfile. It embeds artifact.Metadata for common CI artifact fields and adds planfile-specific fields for Terraform plan data.

func (*Metadata) Validate

func (m *Metadata) Validate() error

Validate checks that required metadata fields are present. Delegates to the embedded artifact.Metadata.Validate() for base field validation, then wraps the error as ErrPlanfileMetadataInvalid for planfile-specific context.

type PlanfileInfo

type PlanfileInfo struct {
	// Key is the storage key/path.
	Key string `json:"key"`

	// Size is the file size in bytes.
	Size int64 `json:"size"`

	// LastModified is when the file was last modified.
	LastModified time.Time `json:"last_modified"`

	// Metadata contains the planfile metadata if available.
	Metadata *Metadata `json:"metadata,omitempty"`
}

PlanfileInfo contains basic information about a stored planfile.

type Query

type Query = artifact.Query

Type aliases to align planfile types with artifact types.

type Store

type Store interface {
	// Name returns the store type name (e.g., "aws/s3", "azure/blob", "google/gcs", "github/artifacts", "local/dir").
	Name() string

	// Upload uploads a planfile to the store.
	Upload(ctx context.Context, name string, files []FileEntry, metadata *Metadata) error

	// Download downloads a planfile from the store.
	Download(ctx context.Context, name string) ([]FileResult, *Metadata, error)

	// Delete deletes a planfile from the store.
	Delete(ctx context.Context, name string) error

	// List lists planfiles matching the given query.
	List(ctx context.Context, query Query) ([]PlanfileInfo, error)

	// Exists checks if a planfile exists.
	Exists(ctx context.Context, name string) (bool, error)

	// GetMetadata retrieves metadata for a planfile without downloading the content.
	GetMetadata(ctx context.Context, name string) (*Metadata, error)
}

Store defines the interface for planfile storage backends. Implementations include S3, Azure Blob, GCS, GitHub Artifacts, and local filesystem.

type StoreOptions

type StoreOptions = artifact.StoreOptions

Type aliases to align planfile types with artifact types.

func NewAtmosConfig

func NewAtmosConfig(storeType string, options map[string]any, atmosConfig *schema.AtmosConfiguration) StoreOptions

NewAtmosConfig is a helper to build StoreOptions with an AtmosConfiguration. This is used to bridge from planfile-specific config to artifact StoreOptions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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