Documentation ¶
Index ¶
- func IsEmptyDir(path string) (bool, error)
- func IsIgnoredFile(name string) bool
- type File
- type Module
- type Parser
- func (p Parser) ConfigDirFiles(dir string) (primary, override []string, diags hcl.Diagnostics)
- func (p *Parser) Context() *hcl.EvalContext
- func (p *Parser) IsConfigDir(path string) bool
- func (p *Parser) LoadConfigDir(path string) (*Module, hcl.Diagnostics)
- func (p *Parser) LoadConfigFile(path string) (*File, hcl.Diagnostics)
- func (p *Parser) LoadConfigFileOverride(path string) (*File, hcl.Diagnostics)
- func (p *Parser) Parse(filename string, src []byte) (*File, hcl.Diagnostics)
- type Provider
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEmptyDir ¶
IsEmptyDir returns true if the given filesystem path contains no Tales configuration files.
Unlike the methods of the Parser type, this function always consults the real filesystem, and thus it isn't appropriate to use when working with configuration loaded from a plan file.
func IsIgnoredFile ¶
IsIgnoredFile returns true if the given filename (which must not have a directory path ahead of it) should be ignored as e.g. an editor swap file.
Types ¶
type Module ¶
type Module struct { // Any other caller that constructs a module directly with NewModule may // assign a suitable value to this attribute before using it for other // purposes. It should be treated as immutable by all consumers of Module // values. SourceDir string Variables map[string]cty.Value Providers map[string]*Provider }
Module is a container for a set of configuration constructs that are evaluated within a common namespace.
func NewModule ¶
NewModule takes a list of primary files and a list of override files and produces a *Module by combining the files together.
If there are any conflicting declarations in the given files -- for example, if the same variable name is defined twice -- then the resulting module will be incomplete and error diagnostics will be returned. Careful static analysis of the returned Module is still possible in this case, but the module will probably not be semantically valid.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is the main interface to read configuration files and other related files from disk.
It retains a cache of all files that are loaded so that they can be used to create source code snippets in diagnostics, etc.
func NewParser ¶
NewParser creates and returns a new Parser that reads files from the given filesystem. If a nil filesystem is passed then the system's "real" filesystem will be used, via afero.OsFs.
func (Parser) ConfigDirFiles ¶
ConfigDirFiles returns lists of the primary and override files configuration files in the given directory.
If the given directory does not exist or cannot be read, error diagnostics are returned. If errors are returned, the resulting lists may be incomplete.
func (*Parser) IsConfigDir ¶
IsConfigDir determines whether the given path refers to a directory that exists and contains at least one Fabric config file (with a .hcl extension.).
func (*Parser) LoadConfigDir ¶
LoadConfigDir reads the .tales files in the given directory as config files (using LoadConfigFile) and then combines these files into a single Module.
If this method returns nil, that indicates that the given directory does not exist at all or could not be opened for some reason. Callers may wish to detect this case and ignore the returned diagnostics so that they can produce a more context-aware error message in that case.
If this method returns a non-nil module while error diagnostics are returned then the module may be incomplete but can be used carefully for static analysis.
This file does not consider a directory with no files to be an error, and will simply return an empty module in that case. Callers should first call Parser.IsConfigDir if they wish to recognize that situation.
.hcl files are parsed using the HCL native syntax.
func (*Parser) LoadConfigFile ¶
LoadConfigFile config.
func (*Parser) LoadConfigFileOverride ¶
LoadConfigFileOverride is the same as LoadConfigFile except that it relaxes certain required attribute constraints in order to interpret the given file as an overrides file.