utils

package
v1.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version of rivendell
	Version = "dev"
	// Commit returns rivendell build commit
	Commit = "unknown"
)
View Source
var ErrEmptyStack = stacktrace.NewError("empty stack")

Functions

func Ask

func Ask(question string, possibleValue ...string)

Ask .

func Error

func Error(err error)

Error .

func ExecuteTemplate

func ExecuteTemplate(templateFile string, variables map[string]string) ([]byte, error)

ExecuteTemplate .

func ExecuteTemplateContent added in v1.1.8

func ExecuteTemplateContent(rootDir string, content []byte, variables map[string]string) ([]byte, error)

ExecuteTemplateContent .

func ExpandEnv

func ExpandEnv(s string) string

ExpandEnv replaces $(var) with environment variable value

func ExpectAnswer

func ExpectAnswer(expected string) (bool, error)

ExpectAnswer .

func Fatal

func Fatal(err error)

Fatal .

func FullVersion added in v1.1.6

func FullVersion() string

func GlobFiles

func GlobFiles(includePatterns, excludePatterns []string) ([]string, error)

GlobFiles returns list of files based on inclusion and exclusion pattern

func Info

func Info(msg string, args ...interface{})

Info .

func Info2

func Info2(msg string, args ...interface{})

Info2 .

func Infof added in v1.1.19

func Infof(out io.Writer, msg string, args ...interface{})

Infof .

func Infof2 added in v1.1.19

func Infof2(out io.Writer, msg string, args ...interface{})

Infof2 .

func IsURL added in v1.1.8

func IsURL(p string) bool

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

MergeMaps merges multiple maps into one

func NilArrayToEmpty

func NilArrayToEmpty(a []string) []string

NilArrayToEmpty converts a nil array to empty array if possible

func PrependPaths

func PrependPaths(prefix string, paths []string) []string

PrependPaths prepends a prefix to an array of paths

func StringArrayFilter added in v1.1.8

func StringArrayFilter(a []string, f func(string) bool) []string

func StringArrayMap

func StringArrayMap(a []string, f func(string) string) []string

StringArrayMap .

func StringSliceToMap added in v1.1.1

func StringSliceToMap(s []string) map[string]bool

func Success

func Success(msg string, args ...interface{})

Success .

func Successf added in v1.1.19

func Successf(out io.Writer, msg string, args ...interface{})

Successf .

func TestEnable

func TestEnable() bool

TestEnable .

func Warn

func Warn(msg string, args ...interface{})

Warn .

func Warnf added in v1.1.19

func Warnf(out io.Writer, msg string, args ...interface{})

Warnf .

Types

type Command

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

Command only Unix is supported

func NewCommand

func NewCommand(name string, args ...string) *Command

NewCommand .

func (*Command) CombineOutput

func (cmd *Command) CombineOutput() *Command

CombineOutput to command stdout buffer

func (*Command) RedirectToStandard

func (cmd *Command) RedirectToStandard()

RedirectToStandard os.Stdout and os.Stderr

func (*Command) Run

func (cmd *Command) Run() (*CommandStatus, error)

Run the command. If the command exit non-zero, the returned error is still nil.

func (*Command) SetStderr

func (cmd *Command) SetStderr(w io.Writer)

SetStderr .

func (*Command) SetStdin

func (cmd *Command) SetStdin(content []byte)

SetStdin .

func (*Command) SetStdinReader

func (cmd *Command) SetStdinReader(r io.Reader)

SetStdinReader .

func (*Command) SetStdout

func (cmd *Command) SetStdout(w io.Writer)

SetStdout .

func (*Command) SilenceOutput

func (cmd *Command) SilenceOutput()

SilenceOutput .

type CommandStatus

type CommandStatus struct {
	ExitCode    int
	Stdout      io.Reader
	Stderr      io.Reader
	ElaspedTime time.Duration
}

CommandStatus .

func ExecuteCommand

func ExecuteCommand(command string, args ...string) (*CommandStatus, error)

ExecuteCommand and redirect output to standard output/standard error

func ExecuteCommandSilently

func ExecuteCommandSilently(command string, args ...string) (*CommandStatus, error)

ExecuteCommandSilently .

type StringSet

type StringSet map[string]struct{}

StringSet .

func NewStringSet

func NewStringSet(values ...string) StringSet

NewStringSet .

func (StringSet) Add

func (s StringSet) Add(values ...string)

Add new values to string set

func (StringSet) Exists

func (s StringSet) Exists(value string) bool

Exists checks a value appears in the set or not

func (StringSet) First

func (s StringSet) First() string

First returns first element from the set

func (StringSet) Join

func (s StringSet) Join(another StringSet) StringSet

Join .

func (StringSet) Remove

func (s StringSet) Remove(values ...string)

Remove values from string set

func (StringSet) ToSlice

func (s StringSet) ToSlice() []string

ToSlice converts the string set to a slice

type StringStack added in v1.0.7

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

func NewStringStack added in v1.0.7

func NewStringStack() *StringStack

func (*StringStack) Head added in v1.0.7

func (s *StringStack) Head() (string, error)

func (*StringStack) Pop added in v1.0.7

func (s *StringStack) Pop() (string, error)

func (*StringStack) Push added in v1.0.7

func (s *StringStack) Push(value string)

Jump to

Keyboard shortcuts

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