internal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExitCode = new(int)
View Source
var ExitCodeMap = map[string]int{
	"ok":                         mustParseInt("0"),
	"output file is a directory": mustParseInt("1"),
	"cannot use `stdout` with multiple template files": mustParseInt("10"),
	"file exists and `overwrite` is not set":           mustParseInt("100"),
	"cannot use stdin with multiple files":             mustParseInt("1000"),
	"cannot use `overwrite` with `stdout`":             mustParseInt("10000"),
	"input file does not exist":                        mustParseInt("100000"),
	"cannot use both a pattern match and file input":   mustParseInt("1000000"),
	"folder/tar files as inputs must be the only ones": mustParseInt("10000000"),
}
View Source
var YutcLog zerolog.Logger

Functions

func BuildTemplate

func BuildTemplate(text string, sharedTemplateBuffers []*bytes.Buffer, name string) (*template.Template, error)

func CheckIfFile added in v0.1.0

func CheckIfFile(path string) (bool, error)

CheckIfFile checks if a path is a file, returns a bool pointer and an error if doesn't exist

func CmpStringLength added in v0.1.0

func CmpStringLength(a, b string) int

func CountRecursables added in v0.1.0

func CountRecursables(paths []string) (int, error)

func Exists added in v0.1.0

func Exists(path string) (bool, error)

Exists checks if a path exists, returns a bool pointer and an error if doesn't exist

func GenerateTempDirName added in v0.1.0

func GenerateTempDirName(pattern string) (string, error)

GenerateTempDirName generates a temporary directory name, basically just standard's MktempDir's without the create

func GetDataFromPath

func GetDataFromPath(source, arg string, settings *YutcSettings) (*bytes.Buffer, error)

GetDataFromPath reads from a file, URL, or stdin and returns a buffer with the contents

func GetDataFromReadCloser

func GetDataFromReadCloser(f io.ReadCloser) (*bytes.Buffer, error)

GetDataFromReadCloser reads from a ReadCloser and returns a buffer with the contents

func GetVersion added in v0.0.5

func GetVersion() string

func InitLogger added in v0.0.3

func InitLogger(levelOverride string)

func IsArchive added in v0.0.5

func IsArchive(filePath string) bool

func IsDir added in v0.1.0

func IsDir(path string) (bool, error)

IsDir checks if a path is a directory, returns a bool pointer and an error if doesn't exist

func LoadSharedTemplates

func LoadSharedTemplates(templates []string) []*bytes.Buffer

LoadSharedTemplates reads from a list of shared template files and returns a list of buffers with the contents

func LoadTemplates

func LoadTemplates(templateFiles []string, sharedTemplateBuffers []*bytes.Buffer) ([]*template.Template, error)

func MergeData

func MergeData(dataFiles []string) (map[string]any, error)

MergeData merges data from a list of data files and returns a map of the merged data. The data is merged in the order of the data files, with later files overriding earlier ones. Supports files supported by ParseFileStringFlag.

func NormalizeFilepath added in v0.1.0

func NormalizeFilepath(file string) string

func ParseFileStringFlag

func ParseFileStringFlag(v string) (string, error)

ParseFileStringFlag determines the source of a file string flag based on format and returns the source as a string, or an error if the source is not supported. Currently, supports "file", "url", and "stdin" (as `-`).

func PrintVersion

func PrintVersion()

func ReadTar added in v0.0.5

func ReadTar(filePath string) ([]filePathMap, error)

func ReadUrl added in v0.1.0

func ReadUrl(templatePath string) (string, []byte, string, error)

func ValidateArguments

func ValidateArguments(settings *YutcSettings) (code int, errs []error)

ValidateArguments checks the arguments for the CLI and returns a code for the error

func WalkDir added in v0.0.5

func WalkDir(rootPath string) []string

Types

type HttpStatusError added in v0.1.0

type HttpStatusError struct {
	StatusCode int
	Status     string
	Response   http.Response
}

func NewHttpStatusError added in v0.1.0

func NewHttpStatusError(resp *http.Response) *HttpStatusError

func (*HttpStatusError) Error added in v0.1.0

func (e *HttpStatusError) Error() string

func (*HttpStatusError) StatusText added in v0.1.0

func (e *HttpStatusError) StatusText() string

type YutcSettings added in v0.1.0

type YutcSettings struct {
	DataFiles []string `json:"data-files"`

	CommonTemplateFiles []string `json:"common-templates"`

	TemplatePaths []string `json:"template-files"`

	Output           string `json:"output"`
	IncludeFilenames bool   `json:"include-filenames"`
	Overwrite        bool   `json:"overwrite"`

	Version bool `json:"version"`
	Verbose bool `json:"verbose"`

	BearerToken string `json:"bearer-auth"`
	BasicAuth   string `json:"basic-auth"`
}

YutcSettings is a struct to hold all the settings from the CLI

func NewCLISettings added in v0.1.0

func NewCLISettings() *YutcSettings

Jump to

Keyboard shortcuts

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