remote

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2015 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LocalDirectory is the directory created in the working
	// dir to hold the remote state file.
	LocalDirectory = ".terraform"

	// HiddenStateFile is the name of the state file in the
	// LocalDirectory
	HiddenStateFile = "terraform.tfstate"

	// BackupHiddenStateFile is the path we backup the state
	// file to before modifications are made
	BackupHiddenStateFile = "terraform.tfstate.backup"
)

Variables

View Source
var (
	// ErrConflict is used to indicate the upload was rejected
	// due to a conflict on the state
	ErrConflict = fmt.Errorf("Conflicting state file")

	// ErrServerNewer is used to indicate the serial number of
	// the state is newer on the server side
	ErrServerNewer = fmt.Errorf("Server-side Serial is newer")

	// ErrRequireAuth is used if the remote server requires
	// authentication and none is provided
	ErrRequireAuth = fmt.Errorf("Remote server requires authentication")

	// ErrInvalidAuth is used if we provide authentication which
	// is not valid
	ErrInvalidAuth = fmt.Errorf("Invalid authentication")

	// ErrRemoteInternal is used if we get an internal error
	// from the remote server
	ErrRemoteInternal = fmt.Errorf("Remote server reporting internal error")
)

Functions

func CopyFile

func CopyFile(src, dst string) error

CopyFile is used to copy from a source file if it exists to a destination. This is used to create a backup of the state file.

func DeleteState

func DeleteState(conf *terraform.RemoteState) error

DeleteState is used to delete the remote state given the configuration for the remote endpoint.

func EnsureDirectory

func EnsureDirectory() error

EnsureDirectory is used to make sure the local storage directory exists

func ExistsFile

func ExistsFile(path string) (bool, error)

ExistsFile is used to check if a given file exists

func HaveLocalState

func HaveLocalState() (bool, error)

HaveLocalState is used to check if we have a local state file

func HiddenStatePath

func HiddenStatePath() (string, error)

HiddenStatePath is used to return the path to the hidden state file, should there be one. TODO: Rename to LocalStatePath

func Persist

func Persist(r io.Reader) error

Persist is used to write out the state given by a reader (likely being streamed from a remote server) to the local storage.

func PersistState

func PersistState(s *terraform.State) error

PersistState is used to persist out the given terraform state in our local state cache location.

func ReadLocalState

func ReadLocalState() (*terraform.State, []byte, error)

ReadLocalState is used to read and parse the local state file

func ValidConfig

func ValidConfig(conf *terraform.RemoteState) error

ValidConfig does a purely logical validation of the remote config

Types

type AtlasRemoteClient

type AtlasRemoteClient struct {
	// contains filtered or unexported fields
}

AtlasRemoteClient implements the RemoteClient interface for an Atlas compatible server.

func NewAtlasRemoteClient

func NewAtlasRemoteClient(conf map[string]string) (*AtlasRemoteClient, error)

func (*AtlasRemoteClient) DeleteState

func (c *AtlasRemoteClient) DeleteState() error

func (*AtlasRemoteClient) GetState

func (c *AtlasRemoteClient) GetState() (*RemoteStatePayload, error)

func (*AtlasRemoteClient) PutState

func (c *AtlasRemoteClient) PutState(state []byte, force bool) error

type ConsulRemoteClient

type ConsulRemoteClient struct {
	// contains filtered or unexported fields
}

ConsulRemoteClient implements the RemoteClient interface for an Consul compatible server.

func NewConsulRemoteClient

func NewConsulRemoteClient(conf map[string]string) (*ConsulRemoteClient, error)

func (*ConsulRemoteClient) DeleteState

func (c *ConsulRemoteClient) DeleteState() error

func (*ConsulRemoteClient) GetState

func (c *ConsulRemoteClient) GetState() (*RemoteStatePayload, error)

func (*ConsulRemoteClient) PutState

func (c *ConsulRemoteClient) PutState(state []byte, force bool) error

type HTTPRemoteClient

type HTTPRemoteClient struct {
	// contains filtered or unexported fields
}

HTTPRemoteClient implements the RemoteClient interface for an HTTP compatible server.

func NewHTTPRemoteClient

func NewHTTPRemoteClient(conf map[string]string) (*HTTPRemoteClient, error)

func (*HTTPRemoteClient) DeleteState

func (c *HTTPRemoteClient) DeleteState() error

func (*HTTPRemoteClient) GetState

func (c *HTTPRemoteClient) GetState() (*RemoteStatePayload, error)

func (*HTTPRemoteClient) PutState

func (c *HTTPRemoteClient) PutState(state []byte, force bool) error

type RemoteClient

type RemoteClient interface {
	GetState() (*RemoteStatePayload, error)
	PutState(state []byte, force bool) error
	DeleteState() error
}

func NewClientByState

func NewClientByState(remote *terraform.RemoteState) (RemoteClient, error)

NewClientByState is used to construct a client from our remote state.

func NewClientByType

func NewClientByType(ctype string, conf map[string]string) (RemoteClient, error)

NewClientByType is used to construct a RemoteClient based on the configured type.

type RemoteStatePayload

type RemoteStatePayload struct {
	MD5   []byte
	State []byte
}

RemoteStatePayload is used to return the remote state along with associated meta data when we do a remote fetch.

type StateChangeResult

type StateChangeResult int

StateChangeResult is used to communicate to a caller what actions have been taken when updating a state file

const (
	// StateChangeNoop indicates nothing has happened,
	// but that does not indicate an error. Everything is
	// just up to date. (Push/Pull)
	StateChangeNoop StateChangeResult = iota

	// StateChangeInit indicates that there is no local or
	// remote state, and that the state was initialized
	StateChangeInit

	// StateChangeUpdateLocal indicates the local state
	// was updated. (Pull)
	StateChangeUpdateLocal

	// StateChangeUpdateRemote indicates the remote state
	// was updated. (Push)
	StateChangeUpdateRemote

	// StateChangeLocalNewer means the pull was a no-op
	// because the local state is newer than that of the
	// server. This means a Push should take place. (Pull)
	StateChangeLocalNewer

	// StateChangeRemoteNewer means the push was a no-op
	// because the remote state is newer than that of the
	// local state. This means a Pull should take place.
	// (Push)
	StateChangeRemoteNewer

	// StateChangeConflict means that the push or pull
	// was a no-op because there is a conflict. This means
	// there are multiple state definitions at the same
	// serial number with different contents. This requires
	// an operator to intervene and resolve the conflict.
	// Shame on the user for doing concurrent apply.
	// (Push/Pull)
	StateChangeConflict
)

func PushState

func PushState(conf *terraform.RemoteState, force bool) (StateChangeResult, error)

PushState is used to read the local state and update the remote state if necessary. The state push can be 'forced' to override any conflict detection on the server-side.

func RefreshState

func RefreshState(conf *terraform.RemoteState) (StateChangeResult, error)

RefreshState is used to read the remote state given the configuration for the remote endpoint, and update the local state if necessary.

func (StateChangeResult) String

func (sc StateChangeResult) String() string

func (StateChangeResult) SuccessfulPull

func (sc StateChangeResult) SuccessfulPull() bool

SuccessfulPull is used to clasify the StateChangeResult for a pull operation. This is different by operation, but can be used to determine a proper exit code.

func (StateChangeResult) SuccessfulPush

func (sc StateChangeResult) SuccessfulPush() bool

SuccessfulPush is used to clasify the StateChangeResult for a push operation. This is different by operation, but can be used to determine a proper exit code

Jump to

Keyboard shortcuts

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