utils

package
v0.0.0-...-6ca168e Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCmd

func ExecCmd(argcmd string) error

ExecCmd executes a command using the shell

func ExecCmdLines

func ExecCmdLines(argcmd string) ([]string, error)

ExecCmdLines executes a command using the shell, and return the output lines or an error

func RenderTemplate

func RenderTemplate(
	main0 *template.Template,
	vmap map[string]interface{},
	tmap map[string]PrefixRenderer,
	wr io.Writer,
) error

RenderTemplate renders templates respecting indentation Its intended use is for YAML templates check template_test for an example.

Types

type PrefixRenderer

type PrefixRenderer = func(pw *PrefixWriter, params map[string]interface{})

PrefixRenderer writes data to pw

type PrefixWriter

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

PrefixWriter wraps an io.Writer to add a prefix on each line NB: caller is responsble for calling Flush().

func NewPrefixWriter

func NewPrefixWriter(w io.Writer, skipFirst bool) *PrefixWriter

NewPrefixWriter creates a new PrefixWriter

func (*PrefixWriter) AppendNewLineOrDie

func (pw *PrefixWriter) AppendNewLineOrDie(s string)

AppendNewLineOrDie appends a new line and panics in case of an error here PrefixWriter will not scan the input for new lines

func (*PrefixWriter) Done

func (pw *PrefixWriter) Done() error

Done flushes buffered and and ensures prefix stack is empty

func (*PrefixWriter) Flush

func (pw *PrefixWriter) Flush() error

Flush forces PrefixWriter to flush any buffered data

func (*PrefixWriter) PopPrefix

func (pw *PrefixWriter) PopPrefix() string

PopPrefix pops a prefix from the stack

func (*PrefixWriter) Prefix

func (pw *PrefixWriter) Prefix() string

Prefix returns the prefix

func (*PrefixWriter) PushPrefix

func (pw *PrefixWriter) PushPrefix(prefix string)

PushPrefix pushes a prefix to the stack

func (*PrefixWriter) Write

func (pw *PrefixWriter) Write(data []byte) (int, error)

func (*PrefixWriter) WriteOrDie

func (pw *PrefixWriter) WriteOrDie(data []byte)

WriteOrDie writes or panics

func (*PrefixWriter) WriteString

func (pw *PrefixWriter) WriteString(data string) (int, error)

WriteString writes a string

func (*PrefixWriter) WriteStringOrDie

func (pw *PrefixWriter) WriteStringOrDie(data string)

WriteStringOrDie writes a string or panics

Jump to

Keyboard shortcuts

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