terraform: github.com/hashicorp/terraform/config/module Index | Files

package module

import "github.com/hashicorp/terraform/config/module"


Package Files

copy_dir.go get.go inode.go module.go storage.go testing.go tree.go tree_gob.go validate_provider_alias.go versions.go


const RootName = "root"

RootName is the name of the root tree.

func GetCopy Uses

func GetCopy(dst, src string) error

GetCopy is the same as Get except that it downloads a copy of the module represented by source.

This copy will omit and dot-prefixed files (such as .git/, .hg/) and can't be updated on its own.

type GetMode Uses

type GetMode byte

GetMode is an enum that describes how modules are loaded.

GetModeLoad says that modules will not be downloaded or updated, they will only be loaded from the storage.

GetModeGet says that modules can be initially downloaded if they don't exist, but otherwise to just load from the current version in storage.

GetModeUpdate says that modules should be checked for updates and downloaded prior to loading. If there are no updates, we load the version from disk, otherwise we download first and then load.

const (
    GetModeNone GetMode = iota

type Module Uses

type Module struct {
    Name      string
    Source    string
    Version   string
    Providers map[string]string

Module represents the metadata for a single module.

type Storage Uses

type Storage struct {
    // StorageDir is the full path to the directory where all modules will be
    // stored.
    StorageDir string

    // Ui is an optional cli.Ui for user output
    Ui  cli.Ui

    // Mode is the GetMode that will be used for various operations.
    Mode GetMode
    // contains filtered or unexported fields

Storage implements methods to manage the storage of modules. This is used by Tree.Load to query registries, authenticate requests, and store modules locally.

func NewStorage Uses

func NewStorage(dir string, services *disco.Disco) *Storage

NewStorage returns a new initialized Storage object.

func (Storage) GetModule Uses

func (s Storage) GetModule(dst, src string) error

GetModule fetches a module source into the specified directory. This is used as a convenience function by the CLI to initialize a configuration.

type Tree Uses

type Tree struct {
    // contains filtered or unexported fields

Tree represents the module import tree of configurations.

This Tree structure can be used to get (download) new modules, load all the modules without getting, flatten the tree into something Terraform can use, etc.

func NewEmptyTree Uses

func NewEmptyTree() *Tree

NewEmptyTree returns a new tree that is empty (contains no configuration).

func NewTree Uses

func NewTree(name string, c *config.Config) *Tree

NewTree returns a new Tree for the given config structure.

func NewTreeModule Uses

func NewTreeModule(name, dir string) (*Tree, error)

NewTreeModule is like NewTree except it parses the configuration in the directory and gives it a specific name. Use a blank name "" to specify the root module.

func TestTree Uses

func TestTree(t *testing.T, path string) (*Tree, func())

TestTree loads a module at the given path and returns the tree as well as a function that should be deferred to clean up resources.

func (*Tree) Child Uses

func (t *Tree) Child(path []string) *Tree

Child returns the child with the given path (by name).

func (*Tree) Children Uses

func (t *Tree) Children() map[string]*Tree

Children returns the children of this tree (the modules that are imported by this root).

This will only return a non-nil value after Load is called.

func (*Tree) Config Uses

func (t *Tree) Config() *config.Config

Config returns the configuration for this module.

func (*Tree) DeepEach Uses

func (t *Tree) DeepEach(cb func(*Tree))

DeepEach calls the provided callback for the receiver and then all of its descendents in the tree, allowing an operation to be performed on all modules in the tree.

Parents will be visited before their children but otherwise the order is not defined.

func (*Tree) GobDecode Uses

func (t *Tree) GobDecode(bs []byte) error

func (*Tree) GobEncode Uses

func (t *Tree) GobEncode() ([]byte, error)

func (*Tree) Load Uses

func (t *Tree) Load(s *Storage) error

Load loads the configuration of the entire tree.

The parameters are used to tell the tree where to find modules and whether it can download/update modules along the way.

Calling this multiple times will reload the tree.

Various semantic-like checks are made along the way of loading since module trees inherently require the configuration to be in a reasonably sane state: no circular dependencies, proper module sources, etc. A full suite of validations can be done by running Validate (after loading).

func (*Tree) Loaded Uses

func (t *Tree) Loaded() bool

Loaded says whether or not this tree has been loaded or not yet.

func (*Tree) Modules Uses

func (t *Tree) Modules() []*Module

Modules returns the list of modules that this tree imports.

This is only the imports of _this_ level of the tree. To retrieve the full nested imports, you'll have to traverse the tree.

func (*Tree) Name Uses

func (t *Tree) Name() string

Name returns the name of the tree. This will be "<root>" for the root tree and then the module name given for any children.

func (*Tree) Path Uses

func (t *Tree) Path() []string

Path is the full path to this tree.

func (*Tree) String Uses

func (t *Tree) String() string

String gives a nice output to describe the tree.

func (*Tree) Validate Uses

func (t *Tree) Validate() tfdiags.Diagnostics

Validate does semantic checks on the entire tree of configurations.

This will call the respective config.Config.Validate() functions as well as verifying things such as parameters/outputs between the various modules.

Load must be called prior to calling Validate or an error will be returned.

Package module imports 28 packages (graph) and is imported by 368 packages. Updated 2019-07-03. Refresh now. Tools for package owners.