terraform: rename to ModuleVariable
This commit is contained in:
parent
4dfdc52ba0
commit
ad03a21040
|
@ -64,7 +64,7 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
|
|||
&ProvisionerTransformer{},
|
||||
|
||||
// Add module variables
|
||||
&VariableTransformer{Module: b.Module},
|
||||
&ModuleVariableTransformer{Module: b.Module},
|
||||
|
||||
// Add the outputs
|
||||
&OutputTransformer{Module: b.Module},
|
||||
|
|
|
@ -7,8 +7,9 @@ import (
|
|||
"github.com/hashicorp/terraform/config/module"
|
||||
)
|
||||
|
||||
// NodeApplyableVariable represents a variable during the apply step.
|
||||
type NodeApplyableVariable struct {
|
||||
// NodeApplyableModuleVariable represents a module variable input during
|
||||
// the apply step.
|
||||
type NodeApplyableModuleVariable struct {
|
||||
PathValue []string
|
||||
Config *config.Variable // Config is the var in the config
|
||||
Value *config.RawConfig // Value is the value that is set
|
||||
|
@ -16,7 +17,7 @@ type NodeApplyableVariable struct {
|
|||
Module *module.Tree // Antiquated, want to remove
|
||||
}
|
||||
|
||||
func (n *NodeApplyableVariable) Name() string {
|
||||
func (n *NodeApplyableModuleVariable) Name() string {
|
||||
result := fmt.Sprintf("var.%s", n.Config.Name)
|
||||
if len(n.PathValue) > 1 {
|
||||
result = fmt.Sprintf("%s.%s", modulePrefixStr(n.PathValue), result)
|
||||
|
@ -26,7 +27,7 @@ func (n *NodeApplyableVariable) Name() string {
|
|||
}
|
||||
|
||||
// GraphNodeSubPath
|
||||
func (n *NodeApplyableVariable) Path() []string {
|
||||
func (n *NodeApplyableModuleVariable) Path() []string {
|
||||
// We execute in the parent scope (above our own module) so that
|
||||
// we can access the proper interpolations.
|
||||
if len(n.PathValue) > 2 {
|
||||
|
@ -37,7 +38,7 @@ func (n *NodeApplyableVariable) Path() []string {
|
|||
}
|
||||
|
||||
// GraphNodeReferenceGlobal
|
||||
func (n *NodeApplyableVariable) ReferenceGlobal() bool {
|
||||
func (n *NodeApplyableModuleVariable) ReferenceGlobal() bool {
|
||||
// We have to create fully qualified references because we cross
|
||||
// boundaries here: our ReferenceableName is in one path and our
|
||||
// References are from another path.
|
||||
|
@ -45,12 +46,12 @@ func (n *NodeApplyableVariable) ReferenceGlobal() bool {
|
|||
}
|
||||
|
||||
// GraphNodeReferenceable
|
||||
func (n *NodeApplyableVariable) ReferenceableName() []string {
|
||||
func (n *NodeApplyableModuleVariable) ReferenceableName() []string {
|
||||
return []string{n.Name()}
|
||||
}
|
||||
|
||||
// GraphNodeEvalable
|
||||
func (n *NodeApplyableVariable) EvalTree() EvalNode {
|
||||
func (n *NodeApplyableModuleVariable) EvalTree() EvalNode {
|
||||
// If we have no value, do nothing
|
||||
if n.Value == nil {
|
||||
return &EvalNoop{}
|
|
@ -8,21 +8,21 @@ import (
|
|||
"github.com/hashicorp/terraform/dag"
|
||||
)
|
||||
|
||||
// VariableTransformer is a GraphTransformer that adds all the variables
|
||||
// ModuleVariableTransformer is a GraphTransformer that adds all the variables
|
||||
// in the configuration to the graph.
|
||||
//
|
||||
// This only adds variables that either have no dependencies (and therefore
|
||||
// always succeed) or has dependencies that are 100% represented in the
|
||||
// graph.
|
||||
type VariableTransformer struct {
|
||||
type ModuleVariableTransformer struct {
|
||||
Module *module.Tree
|
||||
}
|
||||
|
||||
func (t *VariableTransformer) Transform(g *Graph) error {
|
||||
func (t *ModuleVariableTransformer) Transform(g *Graph) error {
|
||||
return t.transform(g, nil, t.Module)
|
||||
}
|
||||
|
||||
func (t *VariableTransformer) transform(g *Graph, parent, m *module.Tree) error {
|
||||
func (t *ModuleVariableTransformer) transform(g *Graph, parent, m *module.Tree) error {
|
||||
// If no config, no variables
|
||||
if m == nil {
|
||||
return nil
|
||||
|
@ -85,7 +85,7 @@ func (t *VariableTransformer) transform(g *Graph, parent, m *module.Tree) error
|
|||
// NOTE: For now this is just an "applyable" variable. As we build
|
||||
// new graph builders for the other operations I suspect we'll
|
||||
// find a way to parameterize this, require new transforms, etc.
|
||||
node := &NodeApplyableVariable{
|
||||
node := &NodeApplyableModuleVariable{
|
||||
PathValue: normalizeModulePath(m.Path()),
|
||||
Config: v,
|
||||
Value: value,
|
||||
|
|
Loading…
Reference in New Issue