From ad03a21040b006c04841d4c6463df86c129ac5a8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 16 Sep 2016 14:00:21 -0700 Subject: [PATCH] terraform: rename to ModuleVariable --- terraform/graph_builder_apply.go | 2 +- .../{node_variable.go => node_module_variable.go} | 15 ++++++++------- terraform/transform_variable.go | 10 +++++----- 3 files changed, 14 insertions(+), 13 deletions(-) rename terraform/{node_variable.go => node_module_variable.go} (80%) diff --git a/terraform/graph_builder_apply.go b/terraform/graph_builder_apply.go index 93212e210..bb626c89c 100644 --- a/terraform/graph_builder_apply.go +++ b/terraform/graph_builder_apply.go @@ -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}, diff --git a/terraform/node_variable.go b/terraform/node_module_variable.go similarity index 80% rename from terraform/node_variable.go rename to terraform/node_module_variable.go index 0f0f80e9e..c50dfa1d1 100644 --- a/terraform/node_variable.go +++ b/terraform/node_module_variable.go @@ -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{} diff --git a/terraform/transform_variable.go b/terraform/transform_variable.go index 9200f6cff..13c80845e 100644 --- a/terraform/transform_variable.go +++ b/terraform/transform_variable.go @@ -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,