Documentation
¶
Overview ¶
Package state manages terraform state.
Index ¶
- Variables
- func NewCommand(api *otfapi.Client) *cobra.Command
- func NewService(opts Options) *service
- type CLI
- type Client
- func (c *Client) CreateStateVersion(ctx context.Context, opts CreateStateVersionOptions) (*Version, error)
- func (c *Client) DeleteStateVersion(ctx context.Context, svID string) error
- func (c *Client) DownloadCurrentState(ctx context.Context, workspaceID string) ([]byte, error)
- func (c *Client) DownloadState(ctx context.Context, svID string) ([]byte, error)
- func (c *Client) GetCurrentStateVersion(ctx context.Context, workspaceID string) (*Version, error)
- func (c *Client) ListStateVersions(ctx context.Context, workspaceID string, opts resource.PageOptions) (*resource.Page[*Version], error)
- func (c *Client) RollbackStateVersion(ctx context.Context, svID string) (*Version, error)
- type CreateStateVersionOptions
- type File
- type FileOutput
- type Options
- type Output
- type Resource
- type Service
- type StateService
- type StateVersionListOptions
- type Status
- type Version
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSerialNotGreaterThanCurrent = errors.New("the serial provided in the state file is not greater than the serial currently known remotely") ErrSerialMD5Mismatch = errors.New("the MD5 hash of the state provided does not match what is currently known for the same serial number") ErrUploadNonPending = errors.New("cannot upload state to a state version with a non-pending status") )
View Source
var ErrCurrentVersionDeletionAttempt = errors.New("deleting the current state version is not allowed")
Functions ¶
func NewService ¶
func NewService(opts Options) *service
Types ¶
type CLI ¶ added in v0.1.9
type CLI struct {
Service
workspace.WorkspaceService
}
type Client ¶
func (*Client) CreateStateVersion ¶
func (*Client) DeleteStateVersion ¶
func (*Client) DownloadCurrentState ¶
func (*Client) DownloadState ¶
func (*Client) GetCurrentStateVersion ¶
func (*Client) ListStateVersions ¶
type CreateStateVersionOptions ¶
type CreateStateVersionOptions struct {
State []byte // Terraform state file. Optional.
WorkspaceID *string // ID of state version's workspace. Required.
Serial *int64 // State serial number. Required.
}
CreateStateVersionOptions are options for creating a state version.
type File ¶
type File struct {
Version int
TerraformVersion string `json:"terraform_version"`
Serial int64
Lineage string
Outputs map[string]FileOutput
Resources []Resource
}
File is the terraform state file contents
type FileOutput ¶
type FileOutput struct {
Value json.RawMessage
Sensitive bool
}
FileOutput is an output in the terraform state file
func (FileOutput) StringValue ¶ added in v0.1.3
func (r FileOutput) StringValue() string
func (FileOutput) Type ¶ added in v0.1.3
func (r FileOutput) Type() (string, error)
Type determines the HCL type of the output value
type Resource ¶ added in v0.1.3
func (Resource) ModuleName ¶ added in v0.1.3
type Service ¶
type Service interface {
// CreateStateVersion creates a state version for a workspace,
// optionally including the state data, or uploading it later using
// UploadStateVersion.
CreateStateVersion(ctx context.Context, opts CreateStateVersionOptions) (*Version, error)
// DownloadCurrentState downloads the current (latest) state for the given
// workspace.
DownloadCurrentState(ctx context.Context, workspaceID string) ([]byte, error)
ListStateVersions(ctx context.Context, workspaceID string, opts resource.PageOptions) (*resource.Page[*Version], error)
GetCurrentStateVersion(ctx context.Context, workspaceID string) (*Version, error)
GetStateVersion(ctx context.Context, versionID string) (*Version, error)
DeleteStateVersion(ctx context.Context, versionID string) error
// RollbackStateVersion creates a state version by duplicating the
// specified state version and sets it as the current state version for
// the given workspace.
RollbackStateVersion(ctx context.Context, versionID string) (*Version, error)
// UploadState uploads the state data for a state version.
UploadState(ctx context.Context, versionID string, state []byte) error
// DownloadState downloads the state data for a state version.
DownloadState(ctx context.Context, versionID string) ([]byte, error)
GetStateVersionOutput(ctx context.Context, outputID string) (*Output, error)
}
Service is the application Service for state
type StateService ¶
type StateService = Service
Alias services so they don't conflict when nested together in struct
type StateVersionListOptions ¶
type StateVersionListOptions struct {
resource.PageOptions
Organization string `schema:"filter[organization][name],required"`
Workspace string `schema:"filter[workspace][name],required"`
}
StateVersionListOptions represents the options for listing state versions.
type Version ¶
type Version struct {
ID string `jsonapi:"primary,state-versions"`
CreatedAt time.Time `jsonapi:"attribute" json:"created-at"`
Serial int64 `jsonapi:"attribute" json:"serial"`
State []byte `jsonapi:"attribute" json:"state"`
Status Status `jsonapi:"attribute" json:"status"`
Outputs map[string]*Output `jsonapi:"attribute" json:"outputs"`
WorkspaceID string `jsonapi:"attribute" json:"workspace-id"`
}
Version is a specific version of terraform state. It includes important metadata as well as the state file itself.
https://developer.hashicorp.com/terraform/cloud-docs/api-docs/state-versions
Click to show internal directories.
Click to hide internal directories.