factory

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 11 Imported by: 0

README

factory

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exclude

type Exclude struct {
	Paths    []string
	Branches []string
}

type File

type File struct {
	Pipelines []*Pipeline
	Variables *Variables
	Stages    []*Stage
}

func NewFile

func NewFile() *File

func ParseDirectory

func ParseDirectory(path string, recursive bool) ([]*File, hcl.Diagnostics)

ParseDirectory parses the directory at the given path and returns a slice of File pointers and any diagnostics encountered.

If the recursive flag is set to true, it will recursively process subdirectories as well.

Parameters:

  • path: The directory path to process.
  • recursive: A flag indicating whether to process subdirectories recursively.

Returns:

  • []*File: A slice of pointers to the parsed files.
  • hcl.Diagnostics: Any diagnostics encountered during parsing.

func ParseFactoryDirectory

func ParseFactoryDirectory() ([]*File, hcl.Diagnostics)

ParseFactoryDirectory parses the "factory/" directory and returns a slice of File pointers and any diagnostics encountered.

Returns:

  • []*File: A slice of pointers to the parsed files.
  • hcl.Diagnostics: Any diagnostics encountered during parsing.

func (*File) GetEvalContext

func (f *File) GetEvalContext(scopeID *string) *hcl.EvalContext

func (*File) String

func (f *File) String() string

type Filter

type Filter struct {
	Include Include
	Exclude Exclude
}

type Include

type Include struct {
	Paths    []string
	Branches []string
}

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

func NewParser(fs afero.Fs) *Parser

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) DirFiles

func (p *Parser) DirFiles(dir string) (primary []string, diags hcl.Diagnostics)

This is used to find all the files in a module directory. It does this by looking for all files with the .hcl extension in the immediate directory.

func (*Parser) LoadConfigFile

func (p *Parser) LoadConfigFile(path string) (*File, hcl.Diagnostics)

LoadConfigFile loads a configuration file from the specified path and returns the parsed file along with any diagnostics encountered during parsing. It first loads the HCL file from the given path and then parses its content according to the defined schema. The function supports parsing pipeline blocks and filter blocks within them. It logs debug messages for each block type found. Currently, decoding of variables and stage blocks is not implemented. The function returns the parsed file and any encountered diagnostics. check out terraoform\internal\config\parser_config.go line 51

func (*Parser) LoadFiles

func (p *Parser) LoadFiles(paths []string) ([]*File, hcl.Diagnostics)

LoadFiles loads multiple configuration files from the specified paths and returns a slice of File objects along with any diagnostics encountered.

func (*Parser) LoadHCLFile

func (p *Parser) LoadHCLFile(path string) (hcl.Body, hcl.Diagnostics)

LoadHCLFile is a low-level method that reads the file at the given path, parses it, and returns the hcl.Body representing its root. In many cases it is better to use one of the other Load*File methods on this type, which additionally decode the root body in some way and return a higher-level construct.

If the file cannot be read at all -- e.g. because it does not exist -- then this method will return a nil body and error diagnostics. In this case callers may wish to ignore the provided error diagnostics and produce a more context-sensitive error instead.

The file will be parsed using the HCL native syntax unless the filename ends with ".json", in which case the HCL JSON syntax will be used.

type Pipeline

type Pipeline struct {
	Name   string
	Filter *Filter
	Stages []*StageDefinition
}

func NewPipeline

func NewPipeline() *Pipeline

type RunBlock

type RunBlock struct {
	Name     string
	Commands []string
	File     string
}

type Scope

type Scope string
const (
	GlobalScope Scope = "global"
	StageScope  Scope = "stage"
)

type Stage

type Stage struct {
	Name      string
	RunBlocks []RunBlock
}

type StageDefinition

type StageDefinition struct {
	Name       string
	DependsOn  []string
	Namespaces []string
}

type Variables

type Variables struct {
	GlobalVariables map[string]cty.Value
	StageVariables  map[string]map[string]cty.Value
}

Current issues with variables. Resolving the variables such as var.foo or resolving objects var.foo.bar

Scopes, there is only 1 global scope but can be many module and resource scopes.

func NewVariables

func NewVariables() *Variables

func (*Variables) InsertGlobal

func (v *Variables) InsertGlobal(key string, value *cty.Value)

func (*Variables) InsertStage

func (v *Variables) InsertStage(key string, value *cty.Value, scopeID string)

Directories

Path Synopsis
cmd
cli command

Jump to

Keyboard shortcuts

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