configwrite

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 12 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 Changes

type Changes map[string]*File

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

func (Changes) Write added in v0.1.1

func (c Changes) Write() error

type File added in v0.1.1

type File struct {
	Dir           string
	OriginalName  string
	OriginalBytes []byte
	NewName       string
	// contains filtered or unexported fields
}

func ExistingFile added in v0.1.1

func ExistingFile(path string, fs afero.Fs) (*File, error)

func NewFile added in v0.1.1

func NewFile(path string) *File

func (*File) Destination added in v0.1.1

func (f *File) Destination() string

func (*File) Diff added in v0.1.1

func (f *File) Diff() difflib.UnifiedDiff

func (*File) Write added in v0.1.1

func (f *File) Write() error

type RemoteBackend

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

func (*RemoteBackend) Changes

func (b *RemoteBackend) Changes() (Changes, error)

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, error)

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 file changes and an error if changes could not be completed
	Changes() (Changes, error)

	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, error)

type TerraformWorkspace

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

func (*TerraformWorkspace) Changes

func (s *TerraformWorkspace) Changes() (Changes, error)

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, error)

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) (*File, error)

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