graph

package
v3.35.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 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) ResourceSet

DependenciesOf returns a ResourceSet of resources upon which the given resource depends. The resource's parent is included in the returned set.

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.

func (*DependencyGraph) TransitiveDependenciesOf added in v3.18.0

func (dg *DependencyGraph) TransitiveDependenciesOf(r *resource.State) ResourceSet

`TransitiveDependenciesOf` calculates the set of resources that `r` depends on, directly or indirectly. This includes as a `Parent`, a member of r's `Dependencies` list or as a provider.

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

type ResourceSet

type ResourceSet map[*resource.State]bool

ResourceSet represents a set of Resources.

func CopyResourceSet added in v3.18.0

func CopyResourceSet(s ResourceSet) ResourceSet

Produces a shallow copy of `s`.

func NewResourceSetFromArray added in v3.18.0

func NewResourceSetFromArray(arr []*resource.State) ResourceSet

Produces a set from an array.

func (ResourceSet) Intersect

func (s ResourceSet) Intersect(other ResourceSet) ResourceSet

Intersect returns a new set that is the intersection of the two given resource sets.

func (ResourceSet) SetMinus added in v3.18.0

func (s ResourceSet) SetMinus(other ResourceSet) ResourceSet

Computes s - other. Input sets are unchanged. If `other[k] = false`, then `k` will not be removed from `s`.

func (ResourceSet) ToArray added in v3.18.0

func (s ResourceSet) ToArray() []*resource.State

Returns the contents of the set as an array of resources. To ensure determinism, they are sorted by urn.

func (ResourceSet) Union added in v3.18.0

func (s ResourceSet) Union(other ResourceSet) ResourceSet

Produces a new set with elements from both sets. The original sets are unchanged.

func (ResourceSet) UnionWith added in v3.18.0

func (s ResourceSet) UnionWith(other ResourceSet) ResourceSet

Alters `s` to include elements of `other`.

Jump to

Keyboard shortcuts

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