util

package
v2.6.0-SNAPSHOT Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListOfLazyEvaluatedEnvVars []string

ListOfLazyEvaluatedEnvVars -- List of unevaluated environment variables. These are sensitive values or values that may have different values depending on where the integration is run (locally vs. the cloud). These environment variables are evaluated at the time of the integration invocation.

Functions

func Close

func Close(err error, closer io.Closer) error

func CloseQuietly

func CloseQuietly(closer io.Closer)

CloseQuietly unconditionally close an io.Closer It should not be used to replace the Close statement(s).

func ConfigTreePropertySplit

func ConfigTreePropertySplit(property string) []string

ConfigTreePropertySplit Parses a property spec and returns its parts.

func CopyFile

func CopyFile(src, dst string) (int64, error)

func CopyMap

func CopyMap(source map[string]string) map[string]string

CopyMap clones a map of strings.

func DirectoryEmpty

func DirectoryEmpty(directory string) (bool, error)

func DirectoryExists

func DirectoryExists(directory string) (bool, error)

func EncodeXML

func EncodeXML(content interface{}) ([]byte, error)

func EncodeXMLWithoutHeader added in v2.1.0

func EncodeXMLWithoutHeader(content interface{}) ([]byte, error)

func FileExists

func FileExists(name string) (bool, error)

func FindAllDistinctStringSubmatch

func FindAllDistinctStringSubmatch(data string, regexps ...*regexp.Regexp) []string

func FindNamedMatches

func FindNamedMatches(expr string, str string) map[string]string

func GetEnvironmentVariable

func GetEnvironmentVariable(variable string) (string, error)

func IToInt32 added in v2.6.0

func IToInt32(x int) (*int32, error)

IToInt32 attempts to convert safely an int to an int32.

func IToInt8 added in v2.6.0

func IToInt8(x int) (*int8, error)

IToInt8 attempts to convert safely an int to an int8.

func JSONToMap

func JSONToMap(src []byte) (map[string]interface{}, error)

func JSONToYAML

func JSONToYAML(src []byte) ([]byte, error)

func MapToYAML

func MapToYAML(src map[string]interface{}) ([]byte, error)
func NavigateConfigTree(current interface{}, nodes []string) (interface{}, error)

NavigateConfigTree switch to the element in the tree represented by the "nodes" spec and creates intermediary nodes if missing. Nodes specs starting with "[" and ending in "]" are treated as slice indexes.

func Open

func Open(name string) (*os.File, error)

Open a safe wrapper of os.Open.

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

OpenFile a safe wrapper of os.OpenFile.

func RandomString

func RandomString(n int) string

func ReadFile

func ReadFile(filename string) ([]byte, error)

ReadFile a safe wrapper of os.ReadFile.

func RunAndLog

func RunAndLog(ctx context.Context, cmd *exec.Cmd, stdOutF func(string) string, stdErrF func(string) string) error

RunAndLog starts the provided command, scans its standard and error outputs line by line, to feed the provided handlers, and waits until the scans complete and the command returns.

func SortedMapKeys

func SortedMapKeys(m map[string]interface{}) []string

func SortedStringMapKeys

func SortedStringMapKeys(m map[string]string) []string

func StringSliceContains

func StringSliceContains(slice []string, items []string) bool

func StringSliceContainsAnyOf

func StringSliceContainsAnyOf(slice []string, items ...string) bool

func StringSliceExists

func StringSliceExists(slice []string, item string) bool

func StringSliceJoin

func StringSliceJoin(slices ...[]string) []string

func StringSliceUniqueAdd

func StringSliceUniqueAdd(slice *[]string, item string) bool

StringSliceUniqueAdd appends the given item if not already present in the slice.

func StringSliceUniqueConcat

func StringSliceUniqueConcat(slice *[]string, items []string) bool

StringSliceUniqueConcat appends all the items of the "items" slice if they are not already present in the slice.

func SubstringBefore

func SubstringBefore(s string, substr string) string

func WithFile

func WithFile(name string, flag int, perm os.FileMode, consumer func(file *os.File) error) error

WithFile a safe wrapper to process a file.

func WithFileContent

func WithFileContent(name string, consumer func(file *os.File, data []byte) error) error

WithFileContent a safe wrapper to process a file content.

func WithFileReader

func WithFileReader(name string, consumer func(reader io.Reader) error) error

WithFileReader a safe wrapper to process a file.

func WithTempDir

func WithTempDir(pattern string, consumer func(string) error) error

WithTempDir a safe wrapper to deal with temporary directories.

func WriteFileWithBytesMarshallerContent

func WriteFileWithBytesMarshallerContent(basePath string, filePath string, content BytesMarshaller) error

func WriteFileWithContent

func WriteFileWithContent(filePath string, content []byte) error

WriteFileWithContent a safe wrapper to write content to a file.

func WriteToFile

func WriteToFile(filePath string, fileContents string) error

Types

type BytesMarshaller

type BytesMarshaller interface {
	MarshalBytes() ([]byte, error)
}

Directories

Path Synopsis
Package bindings provides APIs to transform Kubernetes objects into Camel URIs equivalents
Package bindings provides APIs to transform Kubernetes objects into Camel URIs equivalents
Package jib contains utilities for jib strategy builds.
Package jib contains utilities for jib strategy builds.
log
Package minikube contains utilities for Minikube deployments
Package minikube contains utilities for Minikube deployments
Package s2i contains utilities for openshift s2i builds.
Package s2i contains utilities for openshift s2i builds.
Package sync provides useful tools to get notified when a file system resource changes
Package sync provides useful tools to get notified when a file system resource changes

Jump to

Keyboard shortcuts

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