utils

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile added in v1.1.0

func CopyFile(src, dest string) error

CopyFile copies file src to file dest. File src must exist. File dest doesn't need to exist nor its parent directories, they will be created if required. Existing dest file will be overwritten.

func CopyFileToDir added in v1.1.0

func CopyFileToDir(src, destDir string) (string, error)

CopyFileToDir copies file src to directory destDir. File src must exist. Directory destDir doesn't need exist nor its parent directories, they will be created if required. The destination file will have the same name as src. If that file already exists, it will be overwritten.

func DeepHashString

func DeepHashString(obj interface{}) string

func GetKey

func GetKey(obj metav1.Object) client.ObjectKey

func GetMapNested added in v1.1.0

func GetMapNested(m map[string]interface{}, key string, keys ...string) (interface{}, bool)

GetMapNested gets the value at the given keys in the given map. It returns nil and false if the map does not contain any of the keys.

func IsNil

func IsNil(v interface{}) bool

func ListFiles added in v1.1.0

func ListFiles(root, pattern string) ([]string, error)

ListFiles lists all files whose names match pattern in root directory and its subdirectories.

func MergeMap

func MergeMap(sources ...map[string]string) map[string]string

MergeMap will take two or more maps, merging the entries of the sources map into a destination map. If both maps share the same key then destination's value for that key will be overwritten with what's in source.

func MergeMapNested added in v1.1.0

func MergeMapNested(allowOverwrite bool, sources ...map[string]interface{}) (map[string]interface{}, error)

MergeMapNested will take two or more maps, merging the entries of the sources map into a destination map. If both maps share the same key then destination's value for that key will be merged with what's in source. The source maps are not modified.

func PutMapNested added in v1.1.0

func PutMapNested(allowOverwrite bool, m map[string]interface{}, val interface{}, key string, keys ...string) error

PutMapNested puts the given value in the given map at the given keys. When a key is not present, the entry is created on the fly; created entries are always of type map[string]interface{} to allow for nested entries to be further inserted.

func ReadLines added in v1.1.0

func ReadLines(file string) ([]string, error)

ReadLines reads all lines in the given file.

func RemoveValue

func RemoveValue(slice []string, value string) []string

func SliceContains

func SliceContains(slice []string, s string) bool

func UnmarshalToMap

func UnmarshalToMap(data []byte) (map[string]interface{}, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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