variable

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MPL-2.0 Imports: 29 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
)

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)
	ErrVariableConflict               = errors.New("variable conflicts with another variable with the same name and type")
)

Functions

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 {
	*otfapi.Client
}

func (*Client) ListEffectiveVariables added in v0.1.9

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

type CreateVariableOptions

type CreateVariableOptions struct {
	Key         *string
	Value       *string
	Description *string
	Category    *VariableCategory
	Sensitive   *bool
	HCL         *bool
	// contains filtered or unexported fields
}

type CreateVariableSetOptions added in v0.1.9

type CreateVariableSetOptions struct {
	Name        string
	Description string
	Global      bool
	Workspaces  []string // workspace IDs
}

type Options

type Options struct {
	WorkspaceAuthorizer internal.Authorizer
	WorkspaceService    *workspace.Service
	RunClient           runClient

	*sql.DB
	*tfeapi.Responder
	html.Renderer
	logr.Logger
}

type Service

type Service struct {
	logr.Logger
	// contains filtered or unexported fields
}

func NewService

func NewService(opts Options) *Service

func (*Service) AddHandlers added in v0.2.2

func (s *Service) AddHandlers(r *mux.Router)

func (*Service) CreateWorkspaceVariable added in v0.1.9

func (s *Service) CreateWorkspaceVariable(ctx context.Context, workspaceID string, opts CreateVariableOptions) (*Variable, error)

func (*Service) DeleteWorkspaceVariable added in v0.1.9

func (s *Service) DeleteWorkspaceVariable(ctx context.Context, variableID string) (*WorkspaceVariable, error)

func (*Service) GetWorkspaceVariable added in v0.1.9

func (s *Service) GetWorkspaceVariable(ctx context.Context, variableID string) (*WorkspaceVariable, error)

func (*Service) ListEffectiveVariables added in v0.1.9

func (s *Service) ListEffectiveVariables(ctx context.Context, runID string) ([]*Variable, error)

func (*Service) ListWorkspaceVariables added in v0.1.9

func (s *Service) ListWorkspaceVariables(ctx context.Context, workspaceID string) ([]*Variable, error)

func (*Service) UpdateWorkspaceVariable added in v0.1.9

func (s *Service) UpdateWorkspaceVariable(ctx context.Context, variableID string, opts UpdateVariableOptions) (*WorkspaceVariable, error)

type UpdateVariableOptions

type UpdateVariableOptions struct {
	Key         *string
	Value       *string
	Description *string
	Category    *VariableCategory
	Sensitive   *bool
	HCL         *bool
	// contains filtered or unexported fields
}

type UpdateVariableSetOptions added in v0.1.9

type UpdateVariableSetOptions struct {
	Name        *string
	Description *string
	Global      *bool
	Workspaces  []string // workspace IDs
}

type Variable

type Variable struct {
	ID          string           `jsonapi:"primary,variables"`
	Key         string           `jsonapi:"attribute" json:"key"`
	Value       string           `jsonapi:"attribute" json:"value"`
	Description string           `jsonapi:"attribute" json:"description"`
	Category    VariableCategory `jsonapi:"attribute" json:"category"`
	Sensitive   bool             `jsonapi:"attribute" json:"sensitive"`
	HCL         bool             `jsonapi:"attribute" json:"hcl"`

	// OTF doesn't use this internally but the go-tfe integration tests
	// expect it to be a random value that changes on every update.
	VersionID string
}

func (*Variable) LogValue

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

func (*Variable) Matches added in v0.1.9

func (v *Variable) Matches(vars []*Variable) bool

Matches determines whether variable is contained in vars, i.e. shares the same ID.

type VariableCategory

type VariableCategory string

VariableCategory is the category of variable

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

func VariableCategoryPtr

func VariableCategoryPtr(v VariableCategory) *VariableCategory

VariableCategoryPtr returns a pointer to the given category type.

type VariableRow added in v0.3.0

type VariableRow struct {
	VariableID  pgtype.Text
	Key         pgtype.Text
	Value       pgtype.Text
	Description pgtype.Text
	Category    pgtype.Text
	Sensitive   pgtype.Bool
	HCL         pgtype.Bool
	VersionID   pgtype.Text
}

type VariableSet added in v0.1.9

type VariableSet struct {
	ID           string
	Name         string
	Description  string
	Global       bool
	Workspaces   []string // workspace IDs
	Organization string   // org name
	Variables    []*Variable
}

VariableSet is a set of variables

func (*VariableSet) LogValue added in v0.1.9

func (s *VariableSet) LogValue() slog.Value

type VariableSetRow added in v0.3.0

type VariableSetRow struct {
	VariableSetID    pgtype.Text
	Global           pgtype.Bool
	Name             pgtype.Text
	Description      pgtype.Text
	OrganizationName pgtype.Text
	Variables        []sqlc.Variable
	WorkspaceIds     []pgtype.Text
}

type WorkspaceVariable added in v0.1.9

type WorkspaceVariable struct {
	*Variable
	WorkspaceID string
}

Jump to

Keyboard shortcuts

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