diy

package
v3.114.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 52 Imported by: 1

Documentation

Overview

Package diy implements the logic for interacting with a diy backend such as AWS S3, Azure blob storage, or GCP cloud storage.

Index

Constants

View Source
const FilePathPrefix = "file://"

Variables

View Source
var (
	// StacksDir is a path under the state's root directory
	// where the diy backend stores stack information.
	StacksDir = filepath.Join(workspace.BookkeepingDir, workspace.StackDir)

	// HistoriesDir is a path under the state's root directory
	// where the diy backend stores histories for all stacks.
	HistoriesDir = filepath.Join(workspace.BookkeepingDir, workspace.HistoryDir)

	// BackupsDir is a path under the state's root directory
	// where the diy backend stores backups of stacks.
	BackupsDir = filepath.Join(workspace.BookkeepingDir, workspace.BackupDir)
)

These should be constants but we can't make a constant from filepath.Join.

View Source
var DisableIntegrityChecking bool

DisableIntegrityChecking can be set to true to disable checkpoint state integrity verification. This is not recommended, because it could mean proceeding even in the face of a corrupted checkpoint state file, but can be used as a last resort when a command absolutely must be run.

Functions

func GetLogsForTarget

func GetLogsForTarget(target *deploy.Target, query operations.LogQuery) ([]operations.LogEntry, error)

GetLogsForTarget fetches stack logs using the config, decrypter, and checkpoint in the given target.

func IsDIYBackendURL

func IsDIYBackendURL(urlstr string) bool

Types

type Backend

type Backend interface {
	backend.Backend

	// Upgrade to the latest state store version.
	Upgrade(ctx context.Context, opts *UpgradeOptions) error
	// contains filtered or unexported methods
}

Backend extends the base backend interface with specific information about diy backends.

func Login

func Login(ctx context.Context, d diag.Sink, url string, project *workspace.Project) (Backend, error)

func New

func New(ctx context.Context, d diag.Sink, originalURL string, project *workspace.Project) (Backend, error)

New constructs a new diy backend, using the given URL as the root for storage. The URL must use one of the schemes supported by the go-cloud blob package. Thes inclue: file, s3, gs, azblob.

type Bucket

type Bucket interface {
	Copy(ctx context.Context, dstKey, srcKey string, opts *blob.CopyOptions) (err error)
	Delete(ctx context.Context, key string) (err error)
	List(opts *blob.ListOptions) *blob.ListIterator
	SignedURL(ctx context.Context, key string, opts *blob.SignedURLOptions) (string, error)
	ReadAll(ctx context.Context, key string) (_ []byte, err error)
	WriteAll(ctx context.Context, key string, p []byte, opts *blob.WriterOptions) (err error)
	Exists(ctx context.Context, key string) (bool, error)
}

Bucket is a wrapper around an underlying gocloud blob.Bucket. It ensures that we pass all paths to it normalized to forward-slash form like it requires.

type UpgradeOptions

type UpgradeOptions struct {
	// ProjectsForDetachedStacks is an optional function that is able to
	// backfill project names for stacks that have no project specified otherwise.
	//
	// It is called with a list of stack names that have no project specified.
	// It should return a list of project names to use for each stack name
	// in the same order.
	// If a returned name is blank, the stack at that position will be skipped
	// in the upgrade process.
	//
	// The length of 'projects' MUST match the length of 'stacks'.
	// If it does not, the upgrade will panic.
	//
	// If this function is not specified,
	// stacks without projects will be skipped during the upgrade.
	ProjectsForDetachedStacks func(stacks []tokens.StackName) (projects []tokens.Name, err error)
}

UpgradeOptions customizes the behavior of the upgrade operation.

Jump to

Keyboard shortcuts

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