當前位置: 首頁>>代碼示例>>Golang>>正文


Golang dag.Set類代碼示例

本文整理匯總了Golang中github.com/hashicorp/terraform/dag.Set的典型用法代碼示例。如果您正苦於以下問題:Golang Set類的具體用法?Golang Set怎麽用?Golang Set使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Set類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: selectTargetedNodes

// Returns the list of targeted nodes. A targeted node is either addressed
// directly, or is an Ancestor of a targeted node. Destroy mode keeps
// Descendents instead of Ancestors.
func (t *TargetsTransformer) selectTargetedNodes(
	g *Graph, addrs []ResourceAddress) (*dag.Set, error) {
	targetedNodes := new(dag.Set)
	for _, v := range g.Vertices() {
		if t.nodeIsTarget(v, addrs) {
			targetedNodes.Add(v)

			// We inform nodes that ask about the list of targets - helps for nodes
			// that need to dynamically expand. Note that this only occurs for nodes
			// that are already directly targeted.
			if tn, ok := v.(GraphNodeTargetable); ok {
				tn.SetTargets(addrs)
			}

			var deps *dag.Set
			var err error
			if t.Destroy {
				deps, err = g.Descendents(v)
			} else {
				deps, err = g.Ancestors(v)
			}
			if err != nil {
				return nil, err
			}

			for _, d := range deps.List() {
				targetedNodes.Add(d)
			}
		}
	}
	return targetedNodes, nil
}
開發者ID:AssertSelenium,項目名稱:terraform,代碼行數:35,代碼來源:transform_targets.go

示例2: selectTargetedNodes

// Returns the list of targeted nodes. A targeted node is either addressed
// directly, or is an Ancestor of a targeted node. Destroy mode keeps
// Descendents instead of Ancestors.
func (t *TargetsTransformer) selectTargetedNodes(
	g *Graph, addrs []ResourceAddress) (*dag.Set, error) {
	targetedNodes := new(dag.Set)
	for _, v := range g.Vertices() {
		if t.nodeIsTarget(v, addrs) {
			targetedNodes.Add(v)

			// We inform nodes that ask about the list of targets - helps for nodes
			// that need to dynamically expand. Note that this only occurs for nodes
			// that are already directly targeted.
			if tn, ok := v.(GraphNodeTargetable); ok {
				tn.SetTargets(addrs)
			}

			var deps *dag.Set
			var err error
			if t.Destroy {
				deps, err = g.Descendents(v)

				// Select any variables that we depend on in case we need them later for
				// interpolating in the count
				ancestors, _ := g.Ancestors(v)
				for _, a := range ancestors.List() {
					if _, ok := a.(*GraphNodeConfigVariableFlat); ok {
						deps.Add(a)
					}
				}
			} else {
				deps, err = g.Ancestors(v)
			}
			if err != nil {
				return nil, err
			}

			for _, d := range deps.List() {
				targetedNodes.Add(d)
			}
		}
	}

	return targetedNodes, nil
}
開發者ID:paultyng,項目名稱:terraform,代碼行數:45,代碼來源:transform_targets.go

示例3: selectTargetedNodes

func (t *TargetsTransformer) selectTargetedNodes(
	g *Graph, addrs []ResourceAddress) (*dag.Set, error) {
	targetedNodes := new(dag.Set)
	for _, v := range g.Vertices() {
		// Keep all providers; they'll be pruned later if necessary
		if r, ok := v.(GraphNodeProvider); ok {
			targetedNodes.Add(r)
			continue
		}

		// For the remaining filter, we only care about addressable nodes
		r, ok := v.(GraphNodeAddressable)
		if !ok {
			continue
		}

		if t.nodeIsTarget(r, addrs) {
			targetedNodes.Add(r)
			// If the node would like to know about targets, tell it.
			if n, ok := r.(GraphNodeTargetable); ok {
				n.SetTargets(addrs)
			}

			var deps *dag.Set
			var err error
			if t.Destroy {
				deps, err = g.Descendents(r)
			} else {
				deps, err = g.Ancestors(r)
			}
			if err != nil {
				return nil, err
			}

			for _, d := range deps.List() {
				targetedNodes.Add(d)
			}
		}
	}
	return targetedNodes, nil
}
開發者ID:jrperritt,項目名稱:terraform,代碼行數:41,代碼來源:transform_targets.go


注:本文中的github.com/hashicorp/terraform/dag.Set類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。