Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoQueries = errors.New("no terraform entities found, looks empty") ErrNoKnownProvider = errors.New("terraform providers are not yet supported") ErrNoProviders = errors.New("no valid providers found") )
Errors that might be returned from procesing the HCL
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { ProviderConfig map[string]ProviderConfig `json:"provider_config"` RootModule ConfigurationModule `json:"root_module"` }
Configuration is a Terraform plan configuration.
type ConfigurationModule ¶
type ConfigurationModule struct { Resources []ConfigurationResource `json:"resources"` Variables map[string]Variable `json:"variables"` ModuleCalls map[string]struct { Module *ConfigurationModule `json:"module"` } `json:"module_calls"` }
ConfigurationModule is used to configure a module.
type ConfigurationResource ¶
type ConfigurationResource struct { Address string `json:"address"` ProviderConfigKey string `json:"provider_config_key"` // Expressions are really similar to the ProviderConfigExpression but we cannot use it (as map[string]ProviderConfigExpression) // as some examples do not match, some are not map[string]ProviderConfigExpression but map[string][]interface{} and some constant_value are not // string but other types Expressions map[string]interface{} `json:"expressions"` ForEachExpression map[string]interface{} `json:"for_each_expression,omitempty"` }
ConfigurationResource is used to configure a single reosurce.
type Module ¶
type Module struct { Address string `json:"address"` Resources []Resource `json:"resources"` ChildModules []*Module `json:"child_modules"` }
Module is a collection of resources.
type Plan ¶
type Plan struct { Configuration Configuration `json:"configuration"` PriorState *State `json:"prior_state"` PlannedValues Values `json:"planned_values"` Variables map[string]Variable `json:"variables"` // contains filtered or unexported fields }
Plan is a representation of a Terraform plan file.
func NewPlan ¶
func NewPlan(providerInitializers ...ProviderInitializer) *Plan
NewPlan returns an empty Plan.
func (*Plan) ExtractPlannedQueries ¶
ExtractPlannedQueries extracts a query.Resource slice from the `planned_values` part of the Plan.
func (*Plan) ExtractPriorQueries ¶
ExtractPriorQueries extracts a query.Resource slice from the `prior_state` part of the Plan.
type Provider ¶
type Provider interface { // Name returns the common name of this Provider. Name() string }
Provider represents a Terraform provider. It extracts price queries from Terraform resources.
type ProviderConfig ¶
type ProviderConfig struct { Name string `json:"name"` Alias string `json:"alias"` Expressions map[string]ProviderConfigExpression `json:"expressions"` }
ProviderConfig is configuration of a provider with the given Name.
func (*ProviderConfig) UnmarshalJSON ¶
func (cfg *ProviderConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON handles the logic of Unmarshaling a ProviderConfig as we have some edge cases we want to not unmarshal as they are not standard/needed and would make things more complex
type ProviderConfigExpression ¶
type ProviderConfigExpression struct { ConstantValue interface{} `json:"constant_value",mapstructure:"constant_value"` References []string `json:"references",mapstructure:"references"` }
ProviderConfigExpression is a single configuration variable of a ProviderConfig.
type ProviderInitializer ¶
type ProviderInitializer struct { // MatchNames contains the names that this ProviderInitializer will match. Most providers will only // have one name (such as `aws`) but some might use multiple names to refer to the same provider // implementation (such as `google` and `google-beta`). MatchNames []string // Provider initializes a Provider instance given the values defined in the config and returns it. // If a provider must be ignored (related to version constraints, etc), please return nil to avoid using it. Provider func(values map[string]interface{}) (Provider, error) }
ProviderInitializer is used to initialize a Provider for each provider name that matches one of the MatchNames.
type Resource ¶
type Resource struct { Address string `json:"address"` // This value is 99% of the time an integer, but it can also be // a string, the implementation on TF side is of 'addrs.InstanceKey' // which can be of type 'IntKey' or 'StringKey' Index interface{} `json:"index"` Mode string `json:"mode"` Type string `json:"type"` Name string `json:"name"` ProviderName string `json:"provider_name"` Values map[string]interface{} `json:"values"` }
Resource is a single Terraform resource definition.
func (*Resource) ToResource ¶
func (r *Resource) ToResource(region string) schema.ResourceDef
type State ¶
type State struct {
Values Values `json:"values"`
}
State is a collection of resource modules.