moduledeps

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2021 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package moduledeps contains types that can be used to describe the providers required for all of the modules in a module tree.

It does not itself contain the functionality for populating such data structures; that's in Terraform core, since this package intentionally does not depend on terraform core to avoid package dependency cycles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	Name      string
	Providers Providers
	Children  []*Module
}

Module represents the dependencies of a single module, as well being a node in a tree of such structures representing the dependencies of an entire configuration.

func (*Module) AllProviderRequirements

func (m *Module) AllProviderRequirements() discovery.PluginRequirements

AllProviderRequirements calls ProviderRequirements for the receiver and all of its descendents, and merges the result into a single PluginRequirements structure that would satisfy all of the modules together.

Requirements returned by this method include only version constraints, and apply no particular SHA256 hash constraint.

func (*Module) Equal

func (m *Module) Equal(other *Module) bool

Equal returns true if the receiver is the root of an identical tree to the other given Module. This is a deep comparison that considers the equality of all downstream modules too.

The children are considered to be ordered, so callers may wish to use SortDescendents first to normalize the order of the slices of child nodes.

The implementation of this function is not optimized since it is provided primarily for use in tests.

func (*Module) ProviderRequirements

func (m *Module) ProviderRequirements() discovery.PluginRequirements

ProviderRequirements produces a PluginRequirements structure that can be used with discovery.PluginMetaSet.ConstrainVersions to identify suitable plugins to satisfy the module's provider dependencies.

This method only considers the direct requirements of the receiver. Use AllPluginRequirements to flatten the dependencies for the entire tree of modules.

Requirements returned by this method include only version constraints, and apply no particular SHA256 hash constraint.

func (*Module) SortChildren

func (m *Module) SortChildren()

SortChildren sorts the Children slice into lexicographic order by name, in-place.

This is primarily useful prior to calling WalkTree so that the walk will proceed in a consistent order.

func (*Module) SortDescendents

func (m *Module) SortDescendents()

SortDescendents is a convenience wrapper for calling SortChildren on the receiver and all of its descendent modules.

func (*Module) WalkTree

func (m *Module) WalkTree(cb WalkFunc) error

WalkTree calls the given callback once for the receiver and then once for each descendent, in an order such that parents are called before their children and siblings are called in the order they appear in the Children slice.

When calling the callback, parent will be nil for the first call for the receiving module, and then set to the direct parent of each module for the subsequent calls.

The path given to the callback is valid only until the callback returns, after which it will be mutated and reused. Callbacks must therefore copy the path slice if they wish to retain it.

If the given callback returns an error, the walk will be aborted at that point and that error returned to the caller.

This function is not thread-safe for concurrent modifications of the data structure, so it's the caller's responsibility to arrange for that should it be needed.

It is safe for a callback to modify the descendents of the "current" module, including the ordering of the Children slice itself, but the callback MUST NOT modify the parent module.

type ProviderDependency

type ProviderDependency struct {
	Constraints discovery.Constraints
	Reason      ProviderDependencyReason
}

ProviderDependency describes the dependency for a particular provider instance, including both the set of allowed versions and the reason for the dependency.

type ProviderDependencyReason

type ProviderDependencyReason int

ProviderDependencyReason is an enumeration of reasons why a dependency might be present.

const (
	// ProviderDependencyExplicit means that there is an explicit "provider"
	// block in the configuration for this module.
	ProviderDependencyExplicit ProviderDependencyReason = iota

	// ProviderDependencyImplicit means that there is no explicit "provider"
	// block but there is at least one resource that uses this provider.
	ProviderDependencyImplicit

	// ProviderDependencyInherited is a special case of
	// ProviderDependencyImplicit where a parent module has defined a
	// configuration for the provider that has been inherited by at least one
	// resource in this module.
	ProviderDependencyInherited

	// ProviderDependencyFromState means that this provider is not currently
	// referenced by configuration at all, but some existing instances in
	// the state still depend on it.
	ProviderDependencyFromState
)

type Providers

type Providers map[addrs.Provider]ProviderDependency

Providers describes a set of provider dependencies for a given module.

Each named provider instance can have one version constraint.

type WalkFunc

type WalkFunc func(path []string, parent *Module, current *Module) error

WalkFunc is a callback type for use with Module.WalkTree

Jump to

Keyboard shortcuts

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