mold

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MoldDataTypeString  = "string"
	MoldDataTypeNumber  = "number"
	MoldDataTypeBoolean = "boolean"
)
View Source
const (
	WriterStdout = "stdout"
)

Variables

View Source
var (
	ErrMissingVariableName             = errors.New("missing environment variable name")
	ErrEnvironmentVariableDoesNotExist = errors.New("environment variable does not exist")
	ErrInvalidDataType                 = errors.New("value does not implement the required type")
	ErrEmptyMold                       = errors.New("mold variables are empty")
)

Functions

This section is empty.

Types

type MoldTemplate

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

MoldTemplate data representation for the MoldTemplate.

func New

func New(r io.Reader, tags *[]string) (*MoldTemplate, error)

New creates a new MoldTemplate from an io.Reader. Use the helper functions to read from the respective input.

func (*MoldTemplate) Generate

func (m *MoldTemplate) Generate() error

Generate runs the main logic to check for any required fields in the mold template and fills the values.

func (*MoldTemplate) GetAllVariables

func (m *MoldTemplate) GetAllVariables() []MoldTemplateVariable

GetAllVariables returns all the variables in the mold.

func (*MoldTemplate) GetVariable

func (m *MoldTemplate) GetVariable(key string) (*MoldTemplateVariable, error)

GetVariable gets a MoldTemplateVariable by key. If the key does not exist an error will be returned.

func (*MoldTemplate) SetPromptReader

func (m *MoldTemplate) SetPromptReader(rd io.Reader)

func (*MoldTemplate) WriteEnvironment

func (m *MoldTemplate) WriteEnvironment(w Writer) error

type MoldTemplateVariable

type MoldTemplateVariable struct {
	Name     string      `yaml:"name"`
	Value    interface{} `yaml:"value"`
	Type     string      `yaml:"type"`
	Required bool        `yaml:"required"`
	Tags     []string    `yaml:"tags"`
}

MoldTemplateVariable data representation for a mold template variable.

func (*MoldTemplateVariable) AllTags added in v0.2.0

func (m *MoldTemplateVariable) AllTags() []string

func (*MoldTemplateVariable) HasTag added in v0.2.0

func (m *MoldTemplateVariable) HasTag(tag string) bool

func (*MoldTemplateVariable) HasTags added in v0.2.0

func (m *MoldTemplateVariable) HasTags() bool

func (*MoldTemplateVariable) String

func (m *MoldTemplateVariable) String() string

type StdoutWriter

type StdoutWriter struct{}

func (*StdoutWriter) Write

func (w *StdoutWriter) Write(envVars []MoldTemplateVariable) error

type Writer

type Writer interface {
	Write([]MoldTemplateVariable) error
}

Jump to

Keyboard shortcuts

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