util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTemplate

func ApplyTemplate(tmpl string, data interface{}) ([]byte, error)

func Copy

func Copy(src string, dst string) error

Copy copies both files and directories

func DebugObject

func DebugObject(ctx context.Context, msg string, obj interface{})

func DeletePath

func DeletePath(ctx context.Context, fileOrFolder string) error

func FileExists

func FileExists(filename string) bool

func GetMutex

func GetMutex(ctx context.Context) (*sync.Mutex, bool)

func IsDryRun

func IsDryRun(ctx context.Context) bool

func JoinPaths

func JoinPaths(ctx context.Context, filePaths ...string) string

If called without any filePaths this just returns the RootPath

func KYAMLFilter

func KYAMLFilter(r io.Reader, w io.Writer, filters ...KYAMLFilterFunc) error

func KYAMLResourceMetaMatcher

func KYAMLResourceMetaMatcher(node *kyaml.RNode, matchStatements ...KYAMLResourceMetaMatch) error

func Logger

func Logger(ctx context.Context) *logrus.Entry

func NewContext

func NewContext(dryRun bool, rootPath string) context.Context

func PathExists

func PathExists(path string) (bool, os.FileInfo)

func Poll

func RandomSHA

func RandomSHA(byteLen int) (string, error)

RandomSHA returns a hex-encoded string from {byteLen} random bytes.

func ReadYAMLFile

func ReadYAMLFile(file string, obj interface{}) error

func WithClusterNumber

func WithClusterNumber(ctx context.Context, n uint16) context.Context

func WithDryRun

func WithDryRun(ctx context.Context, dryRun bool) context.Context

func WithMutex

func WithMutex(ctx context.Context, mux *sync.Mutex) context.Context

func WriteFile

func WriteFile(ctx context.Context, file string, b []byte) error

func WriteYAMLFile

func WriteYAMLFile(ctx context.Context, file string, obj interface{}) error

Types

type ExecUtil

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

func Command

func Command(ctx context.Context, command string, args ...string) *ExecUtil

func ShellCommand

func ShellCommand(ctx context.Context, format string, args ...interface{}) *ExecUtil

func (*ExecUtil) Cmd

func (e *ExecUtil) Cmd() *exec.Cmd

func (*ExecUtil) Run

func (e *ExecUtil) Run() (output string, exitCode int, cmdErr error)

func (*ExecUtil) WithEnv

func (e *ExecUtil) WithEnv(envVars ...string) *ExecUtil

func (*ExecUtil) WithPwd

func (e *ExecUtil) WithPwd(pwd string) *ExecUtil

func (*ExecUtil) WithStdio

func (e *ExecUtil) WithStdio(stdin io.Reader, stdout, stderr io.Writer) *ExecUtil

type KYAMLFilterFunc

type KYAMLFilterFunc func(*kyaml.RNode) (*kyaml.RNode, error)

type KYAMLResourceMetaMatch

type KYAMLResourceMetaMatch struct {
	Kind      string
	Name      string
	Namespace string
	Func      func() error
}

Jump to

Keyboard shortcuts

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