loader

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package loader can load and parse configuration files. Unlike the File structure in config package that will just load a single file this will also parse the file and load all dependencies and load _auto load files that will be merged together with the main configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAutoImports

func AddAutoImports(file *config.File) error

AddAutoImports searches in the directory for file for any auto imports and add them to the list of children.

Types

type Loader

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

Loader client for loading sources

func New

func New(options *Options) *Loader

New creates a new loader client with options

func (*Loader) Load

func (l *Loader) Load(paths []string) (ParsedFileCollection, error)

Load files from path and return list of all ParsedFile found at path. Path can either be a single file or a directory, in which case it will load all files found in directory.

type Options

type Options struct {
	WorkingDirectory string

	// TauDirectory is the directory where tau will store temporary files. This is required
	// for ParsedFile to know location where to download and store files.
	TauDirectory string

	// CacheDirectory where to download cached resources and scripts for processing
	CacheDirectory string

	// Getter to retrieve source code with
	Getter *getter.Client

	// MaxDepth to search for dependencies. Should be enough with 1.
	MaxDepth int
}

Options when loading modules. WorkingDirectory is directory where it will search for files. If this is not set it will default to current working directory

type ParsedFile

type ParsedFile struct {
	*config.File

	TempDir      string
	Config       *config.Config
	Env          map[string]string
	Dependencies map[string]*ParsedFile
	ShouldDelete bool
	// contains filtered or unexported fields
}

ParsedFile is a parsed configuration file. It is a composite of config.File so includes also Config() function to return configuration. For parsed file the Config attribute should be used instead as that prevents it from parsing the config file multiple times. They will both return same result though.

func NewParsedFile

func NewParsedFile(filename string, content []byte, tauDir, cacheDir string) (*ParsedFile, error)

NewParsedFile creates a new parsed file from input parameters. It does not try to read the file on disk, but filename has to be an absolute path to file.

func (ParsedFile) DependencyDir

func (p ParsedFile) DependencyDir(dep string) string

DependencyDir returns the dependency directory for dependency `dep`

func (ParsedFile) IsInitialized added in v0.4.0

func (p ParsedFile) IsInitialized() bool

IsInitialized returns true if the module has been initialized already

func (ParsedFile) ModuleDir

func (p ParsedFile) ModuleDir() string

ModuleDir returns the module directory where source module is downloaded

func (ParsedFile) OverrideFile

func (p ParsedFile) OverrideFile() string

OverrideFile returns name of override file that writes backend configuration etc into module directory.

func (ParsedFile) PlanFile

func (p ParsedFile) PlanFile() string

PlanFile returns name of plan file when running `terraform plan`.

func (ParsedFile) VariableFile

func (p ParsedFile) VariableFile() string

VariableFile returns name of input variable file

type ParsedFileCollection

type ParsedFileCollection []*ParsedFile

ParsedFileCollection is a collection of parsed files. Using this it is easier to perform actions on entire collection

func (ParsedFileCollection) IsAllInitialized

func (c ParsedFileCollection) IsAllInitialized() error

IsAllInitialized checks if all modules have been initilized

func (ParsedFileCollection) Walk added in v0.3.0

func (c ParsedFileCollection) Walk(walkerFunc WalkFunc) error

Walk travers the files in collection and execute them in correct order depending on dependencies. It could do it in parallell but has been limited to do one at the time to not mess up output now

type WalkFunc added in v0.3.0

type WalkFunc func(file *ParsedFile) error

WalkFunc is called when walking the collection

Jump to

Keyboard shortcuts

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