terraform

package
v0.9.22 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCloudToken = errors.New("invalid Terraform Cloud Token")
View Source
var ErrMissingCloudToken = errors.New("no Terraform Cloud token is set")

Functions

func Cmd added in v0.6.3

func Cmd(opts *CmdOptions, args ...string) ([]byte, error)

func CreateConfigFile added in v0.7.10

func CreateConfigFile(dir string, terraformCloudHost string, terraformCloudToken string) (string, error)

func GetUsageOnlyResources added in v0.7.12

func GetUsageOnlyResources() []string

func HasSupportedProvider added in v0.7.3

func HasSupportedProvider(rType string) bool

func IsTerraformDir added in v0.8.0

func IsTerraformDir(path string) bool

func NewDirProvider added in v0.8.0

func NewDirProvider(ctx *config.ProjectContext) schema.Provider

func NewPlanProvider added in v0.8.0

func NewPlanProvider(ctx *config.ProjectContext) schema.Provider

func NewStateJSONProvider added in v0.8.0

func NewStateJSONProvider(ctx *config.ProjectContext) schema.Provider

func NewTerragruntProvider added in v0.9.7

func NewTerragruntProvider(ctx *config.ProjectContext) schema.Provider

func ReadPlanCache added in v0.9.12

func ReadPlanCache(p *DirProvider) ([]byte, error)

func StripSetupTerraformWrapper added in v0.9.14

func StripSetupTerraformWrapper(b []byte) ([]byte, bool)

StripSetupTerraformWrapper removes any output added from the setup-terraform GitHub action terraform wrapper, so we can parse the output of this as valid JSON. It returns the stripped out JSON and a boolean that is true if the wrapper output was found and removed.

func UsePlanCache added in v0.9.12

func UsePlanCache(p *DirProvider) bool

func WritePlanCache added in v0.9.12

func WritePlanCache(p *DirProvider, planJSON []byte)

Types

type CmdError added in v0.6.3

type CmdError struct {
	Stderr []byte
	// contains filtered or unexported fields
}

func (*CmdError) Error added in v0.6.3

func (e *CmdError) Error() string

type CmdOptions added in v0.6.2

type CmdOptions struct {
	TerraformBinary     string
	Dir                 string
	TerraformWorkspace  string
	TerraformConfigFile string
	Env                 map[string]string
	Flags               []string
}

type Configuration added in v0.9.19

type Configuration struct {
	ProviderConfig map[string]ProviderConfig `json:"provider_config"`
	RootModule     ModuleConfig              `json:"root_module"`
}

type DirProvider added in v0.8.0

type DirProvider struct {
	Path string

	IsTerragrunt        bool
	PlanFlags           string
	InitFlags           string
	Workspace           string
	UseState            bool
	TerraformBinary     string
	TerraformCloudHost  string
	TerraformCloudToken string
	Env                 map[string]string
	// contains filtered or unexported fields
}

func (*DirProvider) AddMetadata added in v0.9.0

func (p *DirProvider) AddMetadata(metadata *schema.ProjectMetadata)

func (*DirProvider) DisplayType added in v0.8.0

func (p *DirProvider) DisplayType() string

func (*DirProvider) LoadResources added in v0.8.0

func (p *DirProvider) LoadResources(usage map[string]*schema.UsageData) ([]*schema.Project, error)

func (*DirProvider) Type added in v0.8.0

func (p *DirProvider) Type() string

type HCLProvider added in v0.9.19

type HCLProvider struct {
	Parser   *hcl.Parser
	Provider *PlanJSONProvider
	// contains filtered or unexported fields
}

func NewHCLProvider added in v0.9.19

func NewHCLProvider(ctx *config.ProjectContext, provider *PlanJSONProvider, opts ...hcl.Option) (*HCLProvider, error)

NewHCLProvider returns a HCLProvider with a hcl.Parser initialised using the config.ProjectContext. It will use input flags from either the terraform-plan-flags or top level var and var-file flags to set input vars and files on the underlying hcl.Parser.

func (*HCLProvider) AddMetadata added in v0.9.19

func (p *HCLProvider) AddMetadata(metadata *schema.ProjectMetadata)

func (*HCLProvider) DisplayType added in v0.9.19

func (p *HCLProvider) DisplayType() string

func (*HCLProvider) LoadPlanJSON added in v0.9.22

func (p *HCLProvider) LoadPlanJSON() ([]byte, error)

LoadPlanJSON parses the provided directory and returns it as a Terraform Plan JSON.

func (*HCLProvider) LoadResources added in v0.9.19

func (p *HCLProvider) LoadResources(usage map[string]*schema.UsageData) ([]*schema.Project, error)

LoadResources calls a hcl.Parser to parse the directory config files into hcl.Blocks. It then builds a shallow representation of the terraform plan JSON files from these Blocks, this is passed to the PlanJSONProvider. The PlanJSONProvider uses this shallow representation to actually load Infracost resources.

func (*HCLProvider) Type added in v0.9.19

func (p *HCLProvider) Type() string

type ModuleCall added in v0.9.19

type ModuleCall struct {
	Source       string       `json:"source"`
	ModuleConfig ModuleConfig `json:"module"`
}

type ModuleConfig added in v0.9.22

type ModuleConfig struct {
	Resources   []ResourceData        `json:"resources,omitempty"`
	ModuleCalls map[string]ModuleCall `json:"module_calls,omitempty"`
}

type ModuleOut added in v0.9.22

type ModuleOut struct {
	PlanModule   PlanModule
	ModuleConfig ModuleConfig
}

type Parser added in v0.7.17

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

func NewParser added in v0.7.17

func NewParser(ctx *config.ProjectContext) *Parser

type PlanJSONProvider added in v0.8.0

type PlanJSONProvider struct {
	Path string
	// contains filtered or unexported fields
}

func NewPlanJSONProvider added in v0.8.0

func NewPlanJSONProvider(ctx *config.ProjectContext) *PlanJSONProvider

func (*PlanJSONProvider) AddMetadata added in v0.9.0

func (p *PlanJSONProvider) AddMetadata(metadata *schema.ProjectMetadata)

func (*PlanJSONProvider) DisplayType added in v0.8.0

func (p *PlanJSONProvider) DisplayType() string

func (*PlanJSONProvider) LoadResources added in v0.8.0

func (p *PlanJSONProvider) LoadResources(usage map[string]*schema.UsageData) ([]*schema.Project, error)

func (*PlanJSONProvider) LoadResourcesFromSrc added in v0.9.19

func (p *PlanJSONProvider) LoadResourcesFromSrc(usage map[string]*schema.UsageData, j []byte, spinner *ui.Spinner) ([]*schema.Project, error)

func (*PlanJSONProvider) Type added in v0.8.0

func (p *PlanJSONProvider) Type() string

type PlanModule added in v0.9.22

type PlanModule struct {
	Resources    []ResourceJSON `json:"resources,omitempty"`
	Address      *string        `json:"address,omitempty"`
	ChildModules []PlanModule   `json:"child_modules,omitempty"`
}

type PlanProvider added in v0.8.0

type PlanProvider struct {
	*DirProvider
	Path string
	// contains filtered or unexported fields
}

func (*PlanProvider) DisplayType added in v0.8.0

func (p *PlanProvider) DisplayType() string

func (*PlanProvider) LoadResources added in v0.8.0

func (p *PlanProvider) LoadResources(usage map[string]*schema.UsageData) ([]*schema.Project, error)

func (*PlanProvider) Type added in v0.8.0

func (p *PlanProvider) Type() string

type PlanSchema added in v0.9.19

type PlanSchema struct {
	FormatVersion    string      `json:"format_version"`
	TerraformVersion string      `json:"terraform_version"`
	Variables        interface{} `json:"variables,omitempty"`
	PlannedValues    struct {
		RootModule PlanModule `json:"root_module"`
	} `json:"planned_values"`
	ResourceChanges []ResourceChangesJSON `json:"resource_changes"`
	Configuration   Configuration         `json:"configuration"`
}

type ProviderConfig added in v0.9.19

type ProviderConfig struct {
	Name        string                 `json:"name"`
	Expressions map[string]interface{} `json:"expressions,omitempty"`
}

type ResourceChange added in v0.9.19

type ResourceChange struct {
	Actions []string               `json:"actions"`
	Before  interface{}            `json:"before"`
	After   map[string]interface{} `json:"after"`
}

type ResourceChangesJSON added in v0.9.19

type ResourceChangesJSON struct {
	Address       string         `json:"address"`
	ModuleAddress *string        `json:"module_address,omitempty"`
	Mode          string         `json:"mode"`
	Type          string         `json:"type"`
	Name          string         `json:"name"`
	Index         *int64         `json:"index,omitempty"`
	Change        ResourceChange `json:"change"`
}

type ResourceData added in v0.9.19

type ResourceData struct {
	Address           string                 `json:"address"`
	Mode              string                 `json:"mode"`
	Type              string                 `json:"type"`
	Name              string                 `json:"name"`
	ProviderConfigKey string                 `json:"provider_config_key"`
	Expressions       map[string]interface{} `json:"expressions,omitempty"`
	SchemaVersion     int                    `json:"schema_version"`
	CountExpression   *countExpression       `json:"count_expression,omitempty"`
}

type ResourceJSON added in v0.9.19

type ResourceJSON struct {
	Address       string                 `json:"address"`
	Mode          string                 `json:"mode"`
	Type          string                 `json:"type"`
	Name          string                 `json:"name"`
	Index         *int64                 `json:"index,omitempty"`
	SchemaVersion int                    `json:"schema_version"`
	Values        map[string]interface{} `json:"values"`
}

type ResourceOutput added in v0.9.22

type ResourceOutput struct {
	Planned       ResourceJSON
	Changes       ResourceChangesJSON
	Configuration ResourceData
}

type ResourceRegistryMap added in v0.6.3

type ResourceRegistryMap map[string]*schema.RegistryItem

func GetResourceRegistryMap added in v0.6.0

func GetResourceRegistryMap() *ResourceRegistryMap

func (*ResourceRegistryMap) GetCustomRefIDFunc added in v0.9.19

func (r *ResourceRegistryMap) GetCustomRefIDFunc(resourceDataType string) schema.ReferenceIDFunc

func (*ResourceRegistryMap) GetReferenceAttributes added in v0.9.19

func (r *ResourceRegistryMap) GetReferenceAttributes(resourceDataType string) []string

type RunShowOptions added in v0.9.7

type RunShowOptions struct {
	CmdOptions *CmdOptions
}

type StateJSONProvider added in v0.8.0

type StateJSONProvider struct {
	Path string
	// contains filtered or unexported fields
}

func (*StateJSONProvider) AddMetadata added in v0.9.0

func (p *StateJSONProvider) AddMetadata(metadata *schema.ProjectMetadata)

func (*StateJSONProvider) DisplayType added in v0.8.0

func (p *StateJSONProvider) DisplayType() string

func (*StateJSONProvider) LoadResources added in v0.8.0

func (p *StateJSONProvider) LoadResources(usage map[string]*schema.UsageData) ([]*schema.Project, error)

func (*StateJSONProvider) Type added in v0.8.0

func (p *StateJSONProvider) Type() string

type TerragruntInfo added in v0.9.7

type TerragruntInfo struct {
	ConfigPath string
	WorkingDir string
}

type TerragruntProvider added in v0.9.7

type TerragruntProvider struct {
	Path            string
	TerragruntFlags string
	*DirProvider
	// contains filtered or unexported fields
}

func (*TerragruntProvider) AddMetadata added in v0.9.7

func (p *TerragruntProvider) AddMetadata(metadata *schema.ProjectMetadata)

func (*TerragruntProvider) DisplayType added in v0.9.7

func (p *TerragruntProvider) DisplayType() string

func (*TerragruntProvider) LoadResources added in v0.9.7

func (p *TerragruntProvider) LoadResources(usage map[string]*schema.UsageData) ([]*schema.Project, error)

func (*TerragruntProvider) Type added in v0.9.7

func (p *TerragruntProvider) Type() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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