types

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStateDidNotExisted indicate that the state did not existed
	ErrStateDidNotExisted = errors.New("state did not existed")
	// ErrLockingConflict indicate the lock was already aquired by someone else
	ErrLockingConflict = errors.New("the lock was already aquired by someone else")
	// ErrLockMissing indicate that the lock didn't existed when it was expected/required to
	ErrLockMissing = errors.New("was not locked")
)

Functions

This section is empty.

Types

type ErrLocked

type ErrLocked struct {
	Lock     []byte
	LockInfo *LockInfo
}

ErrLocked indicates the state was already locked by someone else

func (*ErrLocked) Error

func (err *ErrLocked) Error() string

type LockInfo

type LockInfo statemgr.LockInfo

LockInfo represents a TF Lock Metadata.

type RequestMetadata

type RequestMetadata struct {
	ID, Type string
	Params   RequestMetadataParams
}

RequestMetadata stores configuration passed from Terraform as HTTP request.

type RequestMetadataParams

type RequestMetadataParams interface {
	// String is a human-readable representation for requested parameters.
	String() string
}

RequestMetadataParams is a specific params set for a particular backend.

type StorageClient

type StorageClient interface {
	// Parse HTTP request and read storage specific parameters - any error considered "bad request"
	ParseMetadataParams(*http.Request, *RequestMetadata) error

	// Connect to the remote storage and store connection in memory for this Params set
	Connect(RequestMetadataParams) error

	// Disconnect from remote storage if it was connected for this Params set.
	// Must not return any errors - there will be no one to handle them at disconnect.
	Disconnect(RequestMetadataParams)

	// Lock the state for current Params set.
	// Locking must be atomic operation.
	// Even though for the rest of requests checking the lock is a responsibility of backend (via ReadLock function),
	// the LockState should check if no one else has locked this state and lock it in the atomic way.
	// ErrLockingConflict will be returned if someone else got the lock.
	LockState(RequestMetadataParams, []byte) error

	// ReadStateLock current lock if it exists. Return ErrLockMissing if no lock was found.
	ReadStateLock(RequestMetadataParams) ([]byte, error)

	// Unlock currently locked state for current Params set.
	UnLockState(RequestMetadataParams) error

	// Since force-unlock is broken for HTTP TF backend, client implementtaion must suggest to the user how to workaround it.
	ForceUnLockWorkaroundMessage(RequestMetadataParams) string

	// Read state file from storage
	GetState(RequestMetadataParams) ([]byte, error)

	// Update state in the storage
	UpdateState(RequestMetadataParams, []byte) error

	// Delete state from the storage
	DeleteState(RequestMetadataParams) error
}

StorageClient is a layer responsible for connection with the remote storage.

Jump to

Keyboard shortcuts

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