Documentation
¶
Overview ¶
Package state manages terraform state.
Index ¶
Constants ¶
const (
DefaultStateVersion = 4
)
Variables ¶
This section is empty.
Functions ¶
func NewService ¶
func NewService(opts Options) *service
Types ¶
type Client ¶
type Client struct {
otf.JSONAPIClient
}
Client uses json-api according to the documented terraform cloud state version API [1] that OTF implements (we could use something different, something simpler but since the terraform CLI talks to OTF via json-api we might as well use this too...).
[1] https://developer.hashicorp.com/terraform/cloud-docs/api-docs/state-versions#state-versions-api
func (*Client) CreateStateVersion ¶
type CreateStateVersionOptions ¶ added in v0.0.32
type Options ¶ added in v0.0.32
type Options struct {
logr.Logger
WorkspaceService
WorkspaceAuthorizer otf.Authorizer
otf.Cache
otf.DB
}
type Service ¶ added in v0.0.32
type Service interface {
// CreateStateVersion creates a state version for the given workspace using
// the given state data.
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, opts StateVersionListOptions) (*VersionList, error)
GetCurrentStateVersion(ctx context.Context, workspaceID string) (*Version, error)
GetStateVersion(ctx context.Context, versionID string) (*Version, error)
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 ¶ added in v0.0.32
type StateService = Service
type StateVersionListOptions ¶ added in v0.0.32
type StateVersionListOptions struct {
otf.ListOptions
Organization string `schema:"filter[organization][name],required"`
Workspace string `schema:"filter[workspace][name],required"`
}
StateVersionListOptions represents the options for listing state versions.
type Version ¶ added in v0.0.32
type Version struct {
ID string
CreatedAt time.Time
Serial int64
State []byte // state file
Outputs outputList // state version has many outputs
WorkspaceID string // state version belongs to a workspace
}
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
type VersionList ¶ added in v0.0.32
type VersionList struct {
*otf.Pagination
Items []*Version
}
VersionList represents a list of state versions.
type WorkspaceService ¶ added in v0.0.32
Alias services so they don't conflict when nested together in struct