utils

package
v5.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RED    = ansi.ColorFunc("red")
	YELLOW = ansi.ColorFunc("yellow")
	GREEN  = ansi.ColorFunc("green")
	GRAY   = ansi.ColorFunc("black+h")
)

Variables for colors. Expand the color pallete here

Functions

func CreateDirectory

func CreateDirectory(directoryPath string) error

CreateDirectory creates a directory with full permissions

func DecryptString

func DecryptString(encryptedRaw string, keyBase string) (plainTextString string, err error)

DecryptString descryptin encrypted string with keybase

func EncryptAES

func EncryptAES(key, data []byte) ([]byte, error)

EncryptAES encrypts data with provided key

func EncryptString

func EncryptString(plain string, keyBase string) (string, error)

EncryptString encrypts plain string with the provided keybase (AES)

func Fetch

func Fetch(fromFile, prefix string) ([]string, error)

Fetch data from a file with a provided prefix

func FindFiles

func FindFiles(dir string) ([]fs.DirEntry, error)

FindFiles finds the files in provided directory

func GetEnvVars

func GetEnvVars(prefix string) []string

GetEnvVars returns the environments variables

func Gray

func Gray(format string) string

Gray wrapper for a string

func Green

func Green(format string) string

Green wrapper for a string

func PrettyPrint

func PrettyPrint(b []byte) ([]byte, error)

PrettyPrint prints json with pretty identation

func PrintLogLines

func PrintLogLines(logs []api.LogLine) error

PrintLogLines prints lines as logs

func ReadLines

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

ReadLines reads a file and returns the string contents

func Red

func Red(format string) string

Red wrapper for a string

func RichLog

func RichLog(level string, log string)

RichLog based on level logs properly

func StringInSlice

func StringInSlice(str string, list []string) bool

StringInSlice check if a string is in slice

func ToHash

func ToHash(plain string) []byte

ToHash hashes with SHA256 the provided string

func ToYaml

func ToYaml(o interface{}) ([]byte, error)

ToYaml transforms interface data to Yaml

func WalkPropertyValueFromArgs

func WalkPropertyValueFromArgs(args []string, actionFunc func(property, value string) error) error

WalkPropertyValueFromArgs walks the proerty values from arguments

func WriteByteFile

func WriteByteFile(fileName string, data []byte) error

WriteByteFile writes to a file from byte data

func WriteBytesFile

func WriteBytesFile(landscapeDir, basePath, fileName string, data []byte) error

WriteBytesFile write bytes to a file to basepath with filename and the given format

func WriteFile

func WriteFile(landscapeDir, basePath, fileName, format string, resource interface{}) error

WriteFile write a file to basepath with filename and the given format

func WriteJSON

func WriteJSON(landscapeDir, basePath, fileName string, resource interface{}) error

WriteJSON write JSON to a file to basepath with filename

func WriteStringFile

func WriteStringFile(fileName string, data []string) error

WriteStringFile writes to a file from string data

func WriteYAML

func WriteYAML(landscapeDir, basePath, fileName string, resource interface{}) error

WriteYAML write YAMLto a file to basepath with filename

func Yellow

func Yellow(format string) string

Yellow wrapper for a string

Types

This section is empty.

Jump to

Keyboard shortcuts

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