util

package
v0.0.0-...-c26f926 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 17 Imported by: 13

Documentation

Overview

Heavily inspired by approach in terraform providers (google, aws etc).

Index

Constants

View Source
const (
	GOOSWindows = "windows"
)

Variables

This section is empty.

Functions

func CheckDir

func CheckDir(path string) (string, bool)

func CheckMatch

func CheckMatch(name string, globs []glob.Glob) bool

func DefaultVarEncoder

func DefaultVarEncoder(c *VarContext, input interface{}) ([]byte, error)

func DefaultVarKeyGetter

func DefaultVarKeyGetter(c *VarContext, vars map[string]interface{}) (val interface{}, err error)

func DirExists

func DirExists(path string) bool

func FileExists

func FileExists(path string) bool

func LimitString

func LimitString(n string, lim int) string

func MapstructureDecode

func MapstructureDecode(in, out interface{}, tag string) error

func MapstructureJSONDecode

func MapstructureJSONDecode(in, out interface{}) error

func MergeMaps

func MergeMaps(a ...map[string]interface{}) map[string]interface{}

func MergeStringMaps

func MergeStringMaps(a ...map[string]string) map[string]string

func MustNewStruct

func MustNewStruct(m map[string]interface{}) *structpb.Struct

func RandomString

func RandomString(length int) string

func RandomStringCrypto

func RandomStringCrypto(length int) string

func RandomStringCryptoCustom

func RandomStringCryptoCustom(lower, upper, numeric, special bool, length int) string

func RandomStringCustom

func RandomStringCustom(lower, upper, numeric, special bool, length int) string

func SHAString

func SHAString(n string) string

func SanitizeEnvVar

func SanitizeEnvVar(in string) string

func SanitizeName

func SanitizeName(n string, allowUnderscore, allowDot bool) string

func StringSliceContains

func StringSliceContains(arr []string, s string) bool

func StripAnsiControl

func StripAnsiControl(in string) string

func WalkWithExclusions

func WalkWithExclusions(dir string, excludes []string, fn func(path, rel string, info os.FileInfo) error) error

Types

type BaseVarEvaluator

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

func NewBaseVarEvaluator

func NewBaseVarEvaluator(vars map[string]interface{}) *BaseVarEvaluator

func (*BaseVarEvaluator) ExpandRaw

func (e *BaseVarEvaluator) ExpandRaw(input []byte) (output []byte, params []interface{}, err error)

func (*BaseVarEvaluator) WithCommentsChar

func (e *BaseVarEvaluator) WithCommentsChar(commentsChar byte) *BaseVarEvaluator

func (*BaseVarEvaluator) WithEncoder

func (e *BaseVarEvaluator) WithEncoder(encoder func(c *VarContext, val interface{}) ([]byte, error)) *BaseVarEvaluator

func (*BaseVarEvaluator) WithIgnoreComments

func (e *BaseVarEvaluator) WithIgnoreComments(ignoreComments bool) *BaseVarEvaluator

func (*BaseVarEvaluator) WithIgnoreInvalid

func (e *BaseVarEvaluator) WithIgnoreInvalid(ignoreInvalid bool) *BaseVarEvaluator

func (*BaseVarEvaluator) WithKeyGetter

func (e *BaseVarEvaluator) WithKeyGetter(keyGetter func(c *VarContext, vars map[string]interface{}) (val interface{}, err error)) *BaseVarEvaluator

func (*BaseVarEvaluator) WithSkipRowColumnInfo

func (e *BaseVarEvaluator) WithSkipRowColumnInfo(skipRowColumnInfo bool) *BaseVarEvaluator

func (*BaseVarEvaluator) WithVarChar

func (e *BaseVarEvaluator) WithVarChar(varChar byte) *BaseVarEvaluator

type MutexKV

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

MutexKV is a simple key/value store for arbitrary mutexes. It can be used to serialize changes across arbitrary collaborators that share knowledge of the keys they must serialize on.

func NewMutexKV

func NewMutexKV() *MutexKV

Returns a properly initialized MutexKV.

func (*MutexKV) Lock

func (m *MutexKV) Lock(key string)

Locks the mutex for the given key. Caller is responsible for calling Unlock for the same key.

func (*MutexKV) Unlock

func (m *MutexKV) Unlock(key string)

Unlock the mutex for the given key. Caller must have called Lock for the same key first.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalMapstructure(interface{}) error
}

type VarContext

type VarContext struct {
	Input            []byte
	Line             []byte
	Row              int
	Token            string
	TokenColumnStart int
	TokenColumnEnd   int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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