configwrite

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TfvarsFilename          = "terraform.tfvars"
	TfvarsAlternateFilename = "terraform.auto.tfvars"
)
View Source
const (
	BackendTypeRemote = "remote"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	File   *hclwrite.File
	Rename string
}

func (*Change) Destination

func (c *Change) Destination(path string) string

func (*Change) WriteFile

func (c *Change) WriteFile(path string) error

type Changes

type Changes map[string]*Change

Changes is a map of changed file objects that should be written to prepare the module for Terraform Cloud

func (Changes) Add

func (c Changes) Add(path string, change *Change) error

func (Changes) WriteFiles

func (c Changes) WriteFiles() error

type RemoteBackend

type RemoteBackend struct {
	Config RemoteBackendConfig
	// contains filtered or unexported fields
}

func (*RemoteBackend) Changes

func (b *RemoteBackend) Changes() (Changes, hcl.Diagnostics)

Changes updates the configured backend

func (*RemoteBackend) Description

func (b *RemoteBackend) Description() string

Description returns a description of the step

func (*RemoteBackend) MultipleWorkspaces

func (b *RemoteBackend) MultipleWorkspaces() bool

MultipleWorkspaces returns whether the remote backend will be configured for multiple prefixed workspaces

func (*RemoteBackend) Name

func (b *RemoteBackend) Name() string

func (*RemoteBackend) WithWriter

func (b *RemoteBackend) WithWriter(w *Writer) Step

type RemoteBackendConfig

type RemoteBackendConfig struct {
	Hostname     string
	Organization string
	Workspaces   WorkspaceConfig
}

type RemoteState

type RemoteState struct {
	Path          string
	RemoteBackend RemoteBackendConfig
	// contains filtered or unexported fields
}

func (*RemoteState) Changes

func (s *RemoteState) Changes() (Changes, hcl.Diagnostics)

Changes updates the configured backend

func (*RemoteState) Description

func (s *RemoteState) Description() string

Description returns a description of the step

func (*RemoteState) Name

func (s *RemoteState) Name() string

func (*RemoteState) WithWriter

func (s *RemoteState) WithWriter(w *Writer) Step

type Step

type Step interface {
	Name() string

	// Description returns a description of the step
	Description() string

	// Changes returns a list of files changes and diagnostics if errors ocurred. If Complete() returns true, this should be empty.
	Changes() (Changes, hcl.Diagnostics)

	WithWriter(*Writer) Step
}

Step is a step required to prepare a module to run in Terraform Cloud

type Steps

type Steps []Step

func NewSteps

func NewSteps(w *Writer, steps Steps) Steps

func (Steps) Append

func (s Steps) Append(steps ...Step) Steps

func (Steps) Changes

func (s Steps) Changes() (Changes, hcl.Diagnostics)

type TerraformWorkspace

type TerraformWorkspace struct {
	Variable string
	// contains filtered or unexported fields
}

func (*TerraformWorkspace) Changes

func (s *TerraformWorkspace) Changes() (Changes, hcl.Diagnostics)

Changes determines changes required to remove terraform.workspace

func (*TerraformWorkspace) Complete

func (s *TerraformWorkspace) Complete() bool

Complete checks if any terraform.workspace replaces are proposed

func (*TerraformWorkspace) Description

func (s *TerraformWorkspace) Description() string

Description returns a description of the step

func (*TerraformWorkspace) Name

func (s *TerraformWorkspace) Name() string

func (*TerraformWorkspace) WithWriter

func (s *TerraformWorkspace) WithWriter(w *Writer) Step

type Tfvars

type Tfvars struct {
	Filename string
	// contains filtered or unexported fields
}

func (*Tfvars) Changes

func (s *Tfvars) Changes() (Changes, hcl.Diagnostics)

Changes determines changes required to remove terraform.workspace

func (*Tfvars) Complete

func (s *Tfvars) Complete() bool

Complete checks if a terraform.tfvars file exists and returns false if it does

func (*Tfvars) Description

func (s *Tfvars) Description() string

Description returns a description of the step

func (*Tfvars) Name

func (s *Tfvars) Name() string

func (*Tfvars) WithWriter

func (s *Tfvars) WithWriter(w *Writer) Step

type WorkspaceConfig

type WorkspaceConfig struct {
	Name   string
	Prefix string
}

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer provides access to information about the Terraform module structure and the ability to update its files

func New

func New(module *configs.Module) *Writer

func (*Writer) Backend

func (w *Writer) Backend() *configs.Backend

Backend returns the backend, or nil if none is defined

func (*Writer) Dir

func (w *Writer) Dir() string

Dir returns the module directory

func (*Writer) File

func (w *Writer) File(path string) (*hclwrite.File, hcl.Diagnostics)

File returns an existing file object or creates and caches one

func (*Writer) HasBackend

func (w *Writer) HasBackend() bool

HasBackend returns true if the module has a backend configuration

func (*Writer) RemoteStateDataSources

func (w *Writer) RemoteStateDataSources() []*configs.Resource

RemoteStateDataSources returns a list of remote state data sources defined for the module

func (*Writer) Variables

func (w *Writer) Variables() map[string]*configs.Variable

Variables returns the declared variables for the module

Jump to

Keyboard shortcuts

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