本文整理匯總了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
}