tfcmigrate

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MPL-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tfcmigrate reads what's needed to move a workspace off HCP Terraform or Terraform Enterprise: its current state, its settings, and its variables. It only reads. Nothing in HCP Terraform is changed.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoState = errors.New("the workspace has no state")

ErrNoState means the workspace exists but has never stored any state.

Functions

func CIInitFlags

func CIInitFlags(ws *Workspace) []string

CIInitFlags suggests "bogform ci init" flags that keep the workspace's behavior.

func PipelineEnv

func PipelineEnv(v Variable) string

PipelineEnv says how a pipeline passes a variable to Bogform: Terraform variables through TF_VAR_<name>, and environment variables under their own name.

func SecretName

func SecretName(v Variable) string

SecretName suggests the pipeline secret that should hold a variable.

func WriteReport

func WriteReport(w io.Writer, ws *Workspace, vars []Variable, showValues bool)

WriteReport prints what a migration needs besides the state: settings, variables, and the next steps. Variable values are shown only when showValues is set, and never for sensitive variables.

Types

type Client

type Client struct {
	// BaseURL is the API's root, such as https://app.terraform.io/api/v2.
	BaseURL string
	// Token is the API token. It's sent only to BaseURL's host.
	Token string
	// HTTP is the client used for requests. A default with a timeout is used if it's nil.
	HTTP *http.Client
}

Client talks to the HCP Terraform API (v2) of one host.

func NewClient

func NewClient(hostname, token string) *Client

NewClient returns a client for a hostname such as app.terraform.io.

func (*Client) CurrentStateVersion

func (c *Client) CurrentStateVersion(ctx context.Context, workspaceID string) (*StateVersion, error)

CurrentStateVersion describes the workspace's latest state. It returns ErrNoState if there's none.

func (*Client) DownloadState

func (c *Client) DownloadState(ctx context.Context, version *StateVersion) ([]byte, error)

DownloadState returns the raw state file of a state version.

func (*Client) Variables

func (c *Client) Variables(ctx context.Context, workspaceID string) ([]Variable, error)

Variables lists a workspace's own variables. Variables from variable sets aren't included.

func (*Client) Workspace

func (c *Client) Workspace(ctx context.Context, organization, name string) (*Workspace, error)

Workspace looks up a workspace by organization and name.

type StateVersion

type StateVersion struct {
	ID          string
	Serial      int64
	CreatedAt   time.Time
	DownloadURL string
}

StateVersion describes a state version without its contents.

type Variable

type Variable struct {
	Key       string
	Value     string
	Category  string // "terraform" or "env"
	HCL       bool
	Sensitive bool
}

Variable is a workspace variable. Value is always "" for sensitive variables, which the API doesn't return.

type Workspace

type Workspace struct {
	ID               string
	Name             string
	TerraformVersion string
	WorkingDirectory string
	ExecutionMode    string
	AutoApply        bool
	// VCSRepository is the connected repository, such as "bogware/example", or "" if there's none.
	VCSRepository string
	// VCSBranch is the branch runs come from. "" means the repository's default branch.
	VCSBranch string
}

Workspace is what matters about a workspace when moving it.

Jump to

Keyboard shortcuts

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