planfile

package
v1.208.0-test.13 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegisteredTypes

func GetRegisteredTypes() []string

GetRegisteredTypes returns a list of registered store types.

func Register

func Register(storeType string, factory StoreFactory)

Register registers a store factory for the given type. Both storeType and factory must be non-empty/non-nil.

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 {
	// Stack is the stack name.
	Stack string `json:"stack"`

	// Component is the component name.
	Component string `json:"component"`

	// ComponentPath is the path to the component.
	ComponentPath string `json:"component_path"`

	// SHA is the git commit SHA this plan was generated for.
	SHA string `json:"sha"`

	// BaseSHA is the base commit SHA (target branch) for comparison.
	BaseSHA string `json:"base_sha,omitempty"`

	// Branch is the git branch this plan was generated from.
	Branch string `json:"branch,omitempty"`

	// PRNumber is the pull request number if applicable.
	PRNumber int `json:"pr_number,omitempty"`

	// RunID is the CI run ID.
	RunID string `json:"run_id,omitempty"`

	// Repository is the repository URL or identifier.
	Repository string `json:"repository,omitempty"`

	// CreatedAt is when the planfile was created.
	CreatedAt time.Time `json:"created_at"`

	// ExpiresAt is when the planfile should be considered expired (optional).
	ExpiresAt *time.Time `json:"expires_at,omitempty"`

	// 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"`

	// Custom allows arbitrary key-value pairs for provider-specific metadata.
	Custom map[string]string `json:"custom,omitempty"`
}

Metadata contains metadata about a stored planfile.

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 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, key string, data io.Reader, metadata *Metadata) error

	// Download downloads a planfile from the store.
	Download(ctx context.Context, key string) (io.ReadCloser, *Metadata, error)

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

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

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

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

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

func NewStore

func NewStore(opts StoreOptions) (Store, error)

NewStore creates a new store from the given options.

type StoreFactory

type StoreFactory func(opts StoreOptions) (Store, error)

StoreFactory is a function that creates a Store from options.

type StoreOptions

type StoreOptions struct {
	// Type is the store type (s3, azure, gcs, github, local).
	Type string

	// Options contains type-specific configuration options.
	Options map[string]any

	// AtmosConfig is the Atmos configuration.
	AtmosConfig *schema.AtmosConfiguration
}

StoreOptions contains options for creating a store.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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