本文整理汇总了Golang中github.com/hashicorp/terraform/config/module.Tree.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang Tree.Name方法的具体用法?Golang Tree.Name怎么用?Golang Tree.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/hashicorp/terraform/config/module.Tree
的用法示例。
在下文中一共展示了Tree.Name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: transformSingle
func (t *ModuleVariableTransformer) transformSingle(g *Graph, parent, m *module.Tree) error {
// If we have no vars, we're done!
vars := m.Config().Variables
if len(vars) == 0 {
log.Printf("[TRACE] Module %#v has no variables, skipping.", m.Path())
return nil
}
// Look for usage of this module
var mod *config.Module
for _, modUse := range parent.Config().Modules {
if modUse.Name == m.Name() {
mod = modUse
break
}
}
if mod == nil {
log.Printf("[INFO] Module %#v not used, not adding variables", m.Path())
return nil
}
// Build the reference map so we can determine if we're referencing things.
refMap := NewReferenceMap(g.Vertices())
// Add all variables here
for _, v := range vars {
// Determine the value of the variable. If it isn't in the
// configuration then it was never set and that's not a problem.
var value *config.RawConfig
if raw, ok := mod.RawConfig.Raw[v.Name]; ok {
var err error
value, err = config.NewRawConfig(map[string]interface{}{
v.Name: raw,
})
if err != nil {
// This shouldn't happen because it is already in
// a RawConfig above meaning it worked once before.
panic(err)
}
}
// Build the node.
//
// 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 := &NodeApplyableModuleVariable{
PathValue: normalizeModulePath(m.Path()),
Config: v,
Value: value,
Module: t.Module,
}
if !t.DisablePrune {
// If the node is not referenced by anything, then we don't need
// to include it since it won't be used.
if matches := refMap.ReferencedBy(node); len(matches) == 0 {
log.Printf(
"[INFO] Not including %q in graph, nothing depends on it",
dag.VertexName(node))
continue
}
}
// Add it!
g.Add(node)
}
return nil
}