Documentation ¶
Index ¶
- Constants
- func GetCopy(dst, src string) error
- type GetMode
- type Module
- type Storage
- type Tree
- func (t *Tree) Child(path []string) *Tree
- func (t *Tree) Children() map[string]*Tree
- func (t *Tree) Config() *config.Config
- func (t *Tree) DeepEach(cb func(*Tree))
- func (t *Tree) GobDecode(bs []byte) error
- func (t *Tree) GobEncode() ([]byte, error)
- func (t *Tree) Load(s *Storage) error
- func (t *Tree) Loaded() bool
- func (t *Tree) Modules() []*Module
- func (t *Tree) Name() string
- func (t *Tree) Path() []string
- func (t *Tree) String() string
Constants ¶
const RootName = "root"
RootName is the name of the root tree.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GetMode ¶
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.
type Storage ¶
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 }
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 ¶
NewStorage returns a new initialized Storage object.
type Tree ¶
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 ¶
func NewEmptyTree() *Tree
NewEmptyTree returns a new tree that is empty (contains no configuration).
func NewTreeFs ¶
NewTreeFs is like NewTree except it parses the configuration in the virtual filesystem and gives it a specific name. Use a blank name "" to specify the root module.
func NewTreeModule ¶
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 ¶
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) Children ¶
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) DeepEach ¶
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) Load ¶
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.
func (*Tree) Modules ¶
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.