variable

package
v0.0.52 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package variable manages terraform workspace variables

Index

Constants

View Source
const (
	// https://developer.hashicorp.com/terraform/cloud-docs/workspaces/variables/managing-variables#character-limits
	VariableDescriptionMaxChars = 512
	VariableKeyMaxChars         = 128
	VariableValueMaxKB          = 256 // 256*1024 bytes

	CategoryTerraform VariableCategory = "terraform"
	CategoryEnv       VariableCategory = "env"
)

Variables

View Source
var (
	ErrVariableDescriptionMaxExceeded = fmt.Errorf("maximum variable description size (%d chars) exceeded", VariableDescriptionMaxChars)
	ErrVariableKeyMaxExceeded         = fmt.Errorf("maximum variable key size (%d chars) exceeded", VariableKeyMaxChars)
	ErrVariableValueMaxExceeded       = fmt.Errorf("maximum variable value size of %d KB exceeded", VariableValueMaxKB)
)

Functions

func NewService

func NewService(opts Options) *service

func WriteTerraformVars

func WriteTerraformVars(dir string, vars []*Variable) error

WriteTerraformVars writes workspace variables to a file named terraform.tfvars located in the given path. If the file already exists it'll be appended to.

Types

type Client

type Client struct {
	internal.JSONAPIClient
}

func (*Client) ListVariables

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

type CreateVariableOptions

type CreateVariableOptions struct {
	Key         *string
	Value       *string
	Description *string
	Category    *VariableCategory
	Sensitive   *bool
	HCL         *bool
}

type Options

type Options struct {
	WorkspaceAuthorizer internal.Authorizer
	WorkspaceService    workspace.Service

	*sql.DB
	html.Renderer
	logr.Logger
}

type Service

type Service interface {
	CreateVariable(ctx context.Context, workspaceID string, opts CreateVariableOptions) (*Variable, error)
	ListVariables(ctx context.Context, workspaceID string) ([]*Variable, error)
	GetVariable(ctx context.Context, variableID string) (*Variable, error)
	UpdateVariable(ctx context.Context, variableID string, opts UpdateVariableOptions) (*Variable, error)
	DeleteVariable(ctx context.Context, variableID string) (*Variable, error)
}

type UpdateVariableOptions

type UpdateVariableOptions struct {
	Key         *string
	Value       *string
	Description *string
	Category    *VariableCategory
	Sensitive   *bool
	HCL         *bool
}

type Variable

type Variable struct {
	ID          string
	Key         string
	Value       string
	Description string
	Category    VariableCategory
	Sensitive   bool
	HCL         bool
	WorkspaceID string
}

func NewTestVariable

func NewTestVariable(t *testing.T, workspaceID string, opts CreateVariableOptions) *Variable

func NewVariable

func NewVariable(workspaceID string, opts CreateVariableOptions) (*Variable, error)

func (*Variable) LogValue

func (v *Variable) LogValue() slog.Value

func (*Variable) Update

func (v *Variable) Update(opts UpdateVariableOptions) error

type VariableCategory

type VariableCategory string

VariableCategory is the category of variable

func VariableCategoryPtr

func VariableCategoryPtr(v VariableCategory) *VariableCategory

VariableCategoryPtr returns a pointer to the given category type.

type VariableService

type VariableService = Service

Jump to

Keyboard shortcuts

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