planfile

package
v1.208.1-test.21 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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"

	// 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 WritePlanfileResults

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

WritePlanfileResults writes downloaded planfile results to disk. It maps PlanFilename to planfilePath 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.

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., "s3", "azure", "gcs", "github", "local").
	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