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