instructions

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: MIT Imports: 16 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 {
	Verbose          bool
	LogLevel         logging.Level
	InstructionsFile string
	OutputDir        string
	StdOut           bool
	Indent           int
	Styles           actions.Styles
	Values           []string
}

Config contains configuration options used with instruction files.

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.

func ReadInstructionFile

func ReadInstructionFile(fileName *string, values interface{}) (*Instructions, error)

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

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.

func (*YamlFile) OpenOutputFile added in v0.2.0

func (yf *YamlFile) OpenOutputFile(o *Config) (*os.File, error)

OpenOutputFile opens or creates a file for outputing results.

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