tfstate

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateVersion = 4
)

Variables

This section is empty.

Functions

func FuncMap

func FuncMap(ctx context.Context, stateLoc string) (template.FuncMap, error)

FuncMap provides a template.FuncMap tfstate based on URL and provide

func FuncMapWithName

func FuncMapWithName(ctx context.Context, name string, stateLoc string) (template.FuncMap, error)

FuncMapWithName provides a template.FuncMap. can lockup values from tfstate.

func JsonnetNativeFuncs

func JsonnetNativeFuncs(ctx context.Context, prefix, stateLoc string) ([]*jsonnet.NativeFunction, error)

JsonnetNativeFuncs provides the native functions for go-jsonnet.

func MustFuncMap

func MustFuncMap(ctx context.Context, stateLoc string) template.FuncMap

MustFuncMap is similar to FuncMap, but panics if it cannot get and parse tfstate.

func MustFuncMapWithName

func MustFuncMapWithName(ctx context.Context, name string, stateLoc string) template.FuncMap

MustFuncMapWithName is similar to FuncMapWithName, but panics if it cannot get and parse tfstate.

Types

type Object

type Object struct {
	Value interface{}
}

func (*Object) Bytes

func (a *Object) Bytes() []byte

func (*Object) MarshalJSON

func (a *Object) MarshalJSON() ([]byte, error)

func (*Object) Query

func (a *Object) Query(query string) (*Object, error)

Query queries object by go-jq

func (*Object) String

func (a *Object) String() string

type TFState

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

TFState represents a tfstate

func Read

func Read(ctx context.Context, src io.Reader) (*TFState, error)

Read reads a tfstate from io.Reader

func ReadFile

func ReadFile(ctx context.Context, file string) (*TFState, error)

ReadFile reads terraform.tfstate from the file (Firstly, a workspace reads TF_WORKSPACE environment variable. if it doesn't exist, it reads from environment file in the same directory)

func ReadURL

func ReadURL(ctx context.Context, loc string) (*TFState, error)

ReadURL reads terraform.tfstate from the URL.

func ReadWithWorkspace

func ReadWithWorkspace(ctx context.Context, src io.Reader, ws string) (*TFState, error)

ReadWithWorkspace reads a tfstate from io.Reader with workspace

func (*TFState) Dump

func (s *TFState) Dump() (map[string]*Object, error)

Dump dumps all resources, outputs, and data sources in tfstate

func (*TFState) FuncMap

func (s *TFState) FuncMap(ctx context.Context) template.FuncMap

func (*TFState) FuncMapWithName

func (s *TFState) FuncMapWithName(ctx context.Context, name string) template.FuncMap

func (*TFState) JsonnetNativeFuncs

func (s *TFState) JsonnetNativeFuncs(ctx context.Context) []*jsonnet.NativeFunction

TFState provides a tfstate.

func (*TFState) JsonnetNativeFuncsWithPrefix

func (s *TFState) JsonnetNativeFuncsWithPrefix(ctx context.Context, prefix string) []*jsonnet.NativeFunction

JsonnetNativeFuncsWithPrefix provides the native functions for go-jsonnet with prefix.

func (*TFState) List

func (s *TFState) List() ([]string, error)

List lists resource and output names in tfstate

func (*TFState) Lookup

func (s *TFState) Lookup(key string) (*Object, error)

Lookup lookups attributes of the specified key in tfstate

Jump to

Keyboard shortcuts

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