graph

package
v3.116.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package graph implements logic for dependency graphs and resource sets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DependencyGraph

type DependencyGraph struct {
	// contains filtered or unexported fields
}

DependencyGraph represents a dependency graph encoded within a resource snapshot.

func NewDependencyGraph

func NewDependencyGraph(resources []*resource.State) *DependencyGraph

NewDependencyGraph creates a new DependencyGraph from a list of resources. The resources should be in topological order with respect to their dependencies, including parents appearing before children.

func (*DependencyGraph) DependenciesOf

func (dg *DependencyGraph) DependenciesOf(res *resource.State) mapset.Set[*resource.State]

DependenciesOf returns a set of resources upon which the given resource depends directly. This includes the resource's provider, parent, any resources in the `Dependencies` list, any resources in the `PropertyDependencies` map, and any resource referenced by the `DeletedWith` field.

func (*DependencyGraph) DependingOn

func (dg *DependencyGraph) DependingOn(res *resource.State,
	ignore map[resource.URN]bool, includeChildren bool,
) []*resource.State

DependingOn returns a slice containing all resources that directly or indirectly depend upon the given resource. The returned slice is guaranteed to be in topological order with respect to the snapshot dependency graph.

The time complexity of DependingOn is linear with respect to the number of resources.

includeChildren adds children as another type of (transitive) dependency.

func (*DependencyGraph) OnlyDependsOn added in v3.105.0

func (dg *DependencyGraph) OnlyDependsOn(res *resource.State) []*resource.State

OnlyDependsOn returns a slice containing all resources that directly or indirectly depend upon *only* the given resource. Resources that also depend on another resource with the same URN will not be included in the returned slice. The returned slice is guaranteed to be in topological order with respect to the snapshot dependency graph.

The time complexity of OnlyDependsOn is linear with respect to the number of resources.

func (*DependencyGraph) TransitiveDependenciesOf added in v3.18.0

func (dg *DependencyGraph) TransitiveDependenciesOf(r *resource.State) mapset.Set[*resource.State]

`TransitiveDependenciesOf` calculates the set of resources upon which the given resource depends, directly or indirectly. This includes the resource's provider, parent, any resources in the `Dependencies` list, any resources in the `PropertyDependencies` map, and any resource referenced by the `DeletedWith` field.

This function is linear in the number of resources in the `DependencyGraph`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL