tfc_api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiClient

type ApiClient interface {
	GetPlanOutput(id string) ([]byte, error)
	GetRun(ctx context.Context, id string) (*tfe.Run, error)
	GetWorkspaceByName(ctx context.Context, org, name string) (*tfe.Workspace, error)
	GetWorkspaceById(ctx context.Context, id string) (*tfe.Workspace, error)
	CreateRunFromSource(ctx context.Context, opts *ApiRunOptions) (*tfe.Run, error)
	LockUnlockWorkspace(ctx context.Context, workspace string, reason string, tag string, lock bool) error
	AddTags(ctx context.Context, workspace string, prefix string, value string) error
	RemoveTagsByQuery(ctx context.Context, workspace string, query string) error
	GetTagsByQuery(ctx context.Context, workspace string, query string) ([]string, error)
}

func NewTFCClient

func NewTFCClient() ApiClient

type ApiRunOptions

type ApiRunOptions struct {
	// IsApply = true if this run is will auto apply
	IsApply bool
	// Path is the path to directory where repo source has been cloned
	Path string
	// Message is the Terraform Cloud run title.
	Message string
	// Organization is the Terraform Cloud organization name
	Organization string
	// Workspace is the Terraform Cloud workspace name
	Workspace string
	// Terraform Version
	TFVersion string
	// Terraform Target
	Target string
	// Terraform AllowEmptyApply
	AllowEmptyRun bool
}

type TFCClient

type TFCClient struct {
	Client *tfe.Client
}

func (*TFCClient) AddTags

func (t *TFCClient) AddTags(ctx context.Context, workspace string, prefix string, value string) error

AddTags Adds a tag to a named terraform workspace. The function returns an error if there's an error generated while trying to add the tags. The tags take the format of prefix dash value, which is just a convention and not required by terraform cloud for naming format. The tag, however, will be lowercased by terraform cloud, and in any retrieval operations.

func (*TFCClient) CreateRunFromSource

func (c *TFCClient) CreateRunFromSource(ctx context.Context, opts *ApiRunOptions) (*tfe.Run, error)

CreateRunFromSource creates a new Terraform Cloud run from source files

func (*TFCClient) GetPlanOutput

func (t *TFCClient) GetPlanOutput(id string) ([]byte, error)

func (*TFCClient) GetRun

func (t *TFCClient) GetRun(ctx context.Context, id string) (*tfe.Run, error)

func (*TFCClient) GetTagsByQuery

func (t *TFCClient) GetTagsByQuery(ctx context.Context, workspace string, query string) ([]string, error)

GetTagsByQuery returns a list of values of tags on a terraform workspace matching the query string. It operates on strings reporesenting the value of the tag and internally converts it to and from the upstreams tag struct as needed. Attempting to query tags based on their tag ID will not match the tag.

func (*TFCClient) GetWorkspaceById

func (t *TFCClient) GetWorkspaceById(ctx context.Context, id string) (*tfe.Workspace, error)

func (*TFCClient) GetWorkspaceByName

func (t *TFCClient) GetWorkspaceByName(ctx context.Context, org, name string) (*tfe.Workspace, error)

func (*TFCClient) LockUnlockWorkspace

func (t *TFCClient) LockUnlockWorkspace(ctx context.Context, workspaceID string, reason string, tag string, lock bool) error

func (*TFCClient) RemoveTagsByQuery

func (t *TFCClient) RemoveTagsByQuery(ctx context.Context, workspace string, query string) error

RemoveTagsByQuery removes all tags matching a query from a terraform cloud workspace. It returns an error if one is returned fom searching or removing tags.// Note: the query will match anywhere in the tag, so common substrings should be avoided.

Jump to

Keyboard shortcuts

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