utils

package
v0.7.17 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDir

func CheckDir(path string) (bool, error)

CheckDir check if 'pash' exists and is directory. error means os.Stat error. true - dir

func CidrSubnet

func CidrSubnet(netCidr string, newbits int, netnum interface{}) (ret string, err error)

func Copy added in v0.5.0

func Copy(srcFile, dstFile string) error

func CopyDirectory added in v0.5.0

func CopyDirectory(scrDir, dest string) error
func CopySymLink(source, dest string) error

func CreateIfNotExists added in v0.5.0

func CreateIfNotExists(dir string, perm os.FileMode) error

func Diff

func Diff(structA, structB interface{}, colored bool) string

func Exists added in v0.5.0

func Exists(filePath string) bool

func FileExists

func FileExists(filename string) bool

FileExists check if file exists.

func FindLineNumInYamlError added in v0.6.0

func FindLineNumInYamlError(err error) []int

func GetFileByUrl added in v0.6.0

func GetFileByUrl(srcUrl string) (string, error)

func GetTemplate

func GetTemplate(gitURL, targetDir, templateName string) (string, error)

func IsAbsolutePath

func IsAbsolutePath(path string) bool

func IsDir

func IsDir(path string) bool

func IsLocalPath

func IsLocalPath(path string) bool

func JSONCopy added in v0.5.2

func JSONCopy(in, out interface{}) error

JSONCopy - convert interface data in to type of out with JSON tags.

func JSONDecode

func JSONDecode(in []byte, out interface{}) error

JSONDecode decode in to .

func JSONEncode

func JSONEncode(in interface{}) ([]byte, error)

JSONEncode encode in to JSON.

func JSONEncodeString added in v0.5.0

func JSONEncodeString(in interface{}) (string, error)

JSONEncode encode in to JSON.

func Md5

func Md5(data string) string

func MergeMaps added in v0.5.2

func MergeMaps(mOne, mTwo map[string]interface{}) (res map[string]interface{})

func NewYamlError added in v0.6.0

func NewYamlError(data []byte, lines []int) string

func RandString added in v0.4.5

func RandString(n int) string

func ReadFilesToExistentsList

func ReadFilesToExistentsList(filesPath, baseDir string, filesList map[string][]byte) (err error)

func ReadFilesToList

func ReadFilesToList(filesPath, baseDir string) (filesList map[string][]byte, err error)

func ReadYAML

func ReadYAML(objData []byte) (res map[string]interface{}, err error)

ReadYAML same as ReadYAMLObjects but parse only data with 1 yaml object.

func ReadYAMLObjects

func ReadYAMLObjects(objData []byte) ([]map[string]interface{}, error)

func ResolveYamlError added in v0.6.0

func ResolveYamlError(data []byte, err error) error

func TerraformJSONOutputParse added in v0.7.9

func TerraformJSONOutputParse(in string) (out map[string]string, stringOut string, err error)

TerraformJSONOutputParse parse data from terraform output --json command to map and line-to-line string

func TruncateString

func TruncateString(src string, maxLen int) string

TruncateString - truncate string src to maxLen.

func URLToFolderName added in v0.7.4

func URLToFolderName(URL string) (string, error)

URLToFolderName convert URL to string which can be used as a directory name.

func WriteFilesFromList

func WriteFilesFromList(path string, filesList map[string]string) (err error)

func YAMLInterfaceToType added in v0.5.0

func YAMLInterfaceToType(in, out interface{}) error

YAMLInterfaceToType - convert interface data in to type of out with YAML tags.

Types

type GitRepo added in v0.4.6

type GitRepo struct {
	URL        string
	RepoString string // Repo url without the protocol and the subdirectory e.g. github.com/org/repo?ref=tag .
	SubDir     string
	Version    string
}

func ParseGitUrl added in v0.4.6

func ParseGitUrl(gitURL string) (repo GitRepo, err error)

Jump to

Keyboard shortcuts

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