planfile

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package planfile deals with the file format used to serialize plans to disk and then deserialize them back into memory later.

A plan file contains the planned changes along with the configuration and state snapshot that they are based on.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(filename string, configSnap *configload.Snapshot, stateFile *statefile.File, plan *plans.Plan) error

Create creates a new plan file with the given filename, overwriting any file that might already exist there.

A plan file contains both a snapshot of the configuration and of the latest state file in addition to the plan itself, so that Terraform can detect if the world has changed since the plan was created and thus refuse to apply it.

Types

type Reader

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

Reader is the main type used to read plan files. Create a Reader by calling Open.

A plan file is a random-access file format, so methods of Reader must be used to access the individual portions of the file for further processing.

func Open

func Open(filename string) (*Reader, error)

Open creates a Reader for the file at the given filename, or returns an error if the file doesn't seem to be a planfile.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the file, after which no other operations may be performed.

func (*Reader) ReadConfig

func (r *Reader) ReadConfig() (*configs.Config, tfdiags.Diagnostics)

ReadConfig reads the configuration embedded in the plan file.

Internally this function delegates to the configs/configload package to parse the embedded configuration and so it returns diagnostics (rather than a native Go error as with other methods on Reader).

func (*Reader) ReadConfigSnapshot

func (r *Reader) ReadConfigSnapshot() (*configload.Snapshot, error)

ReadConfigSnapshot reads the configuration snapshot embedded in the plan file.

This is a lower-level alternative to ReadConfig that just extracts the source files, without attempting to parse them.

func (*Reader) ReadPlan

func (r *Reader) ReadPlan() (*plans.Plan, error)

ReadPlan reads the plan embedded in the plan file.

Errors can be returned for various reasons, including if the plan file is not of an appropriate format version, if it was created by a different version of Terraform, if it is invalid, etc.

func (*Reader) ReadStateFile

func (r *Reader) ReadStateFile() (*statefile.File, error)

ReadStateFile reads the state file embedded in the plan file.

If the plan file contains no embedded state file, the returned error is statefile.ErrNoState.

Jump to

Keyboard shortcuts

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