instructions

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAbsolutePathForOutputPath = errors.New("absolute paths are currently not supported for outputPath")
View Source
var ErrFoundDirectoryWithPathOutput = errors.New("found directory as input path with file as output path")

Functions

func CloseFile

func CloseFile(file *os.File)

CloseFile safely closes a file handle.

func Execute

func Execute(cfg *Config) error

Execute takes in configuratation options and executes overlays on an instruction file specified.

func GetCommonPrefix

func GetCommonPrefix(sep byte, paths ...string) string

GetCommonPrefix determines the longest common prefix in a set of paths.

func PostProcessHandler

func PostProcessHandler(cfg *Config, pChan <-chan *YamlFile) error

PostProcessHandler waits for YamlFile objects and preforms post overlay tasks like rendering, saving to file or displaying to screen.

func ReadStream

func ReadStream(fileName string) (io.Reader, error)

Types

type Config

type Config struct {
	LogLevel               logging.Level
	InstructionsFile       string
	OutputDir              string
	StdOut                 bool
	RemoveComments         bool
	Indent                 int
	Styles                 actions.Styles
	ValueFiles             []string
	Overlay                overlays.Overlay
	Value                  string
	Path                   string
	DefaultOnMissingAction actions.OnMissingAction
}

Config contains configuration options used with instruction files.

func (*Config) GetInstructions added in v0.5.0

func (cfg *Config) GetInstructions() (*Instructions, error)

func (*Config) ReadAdHocOverlays added in v0.5.0

func (cfg *Config) ReadAdHocOverlays(i *Instructions) error

func (*Config) ReadAdHocPaths added in v0.5.0

func (cfg *Config) ReadAdHocPaths(i *Instructions) error

func (*Config) ReadInstructionFile added in v0.5.0

func (cfg *Config) ReadInstructionFile() (*Instructions, error)

ReadInstructionFile reads a file and decodes it into an Instructions struct.

type Document

type Document struct {
	Name     string              `yaml:"name,omitempty"`
	Path     int                 `yaml:"path,omitempty"`
	Overlays []*overlays.Overlay `yaml:"overlays,omitempty"`
}

Document is a set of overlays scoped to a specific document within a yamlfile.

type Instructions

type Instructions struct {
	// Common Overlays that will apply to all files specified.
	CommonOverlays []*overlays.Overlay `yaml:"commonOverlays,omitempty"`
	// List of YamlFiles and overlays to apply.
	YamlFiles YamlFiles `yaml:"yamlFiles,omitempty"`
}

Instructions is a struct used for decoding an instructions file.

type YamlFile

type YamlFile struct {
	// Optional Name to define for organization purposes.
	Name string `yaml:"name,omitempty"`
	// List of Overlays specific to this yamlFile.
	Overlays []*overlays.Overlay `yaml:"overlays,omitempty"`
	// a list of more specific entries and overlays for a specific document within the yamlFile.
	Documents []*Document `yaml:"documents,omitempty"`

	Nodes []*yaml.Node

	Path string `yaml:"path,omitempty"`

	OutputPath string `yaml:"outputPath,omitempty"`
}

YamlFile is used to define which files should be manipulated and overlays specific to that file.

type YamlFiles added in v0.2.0

type YamlFiles []*YamlFile

func (*YamlFiles) UnmarshalYAML added in v0.2.0

func (yfs *YamlFiles) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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