utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFileIfNotExist

func CreateFileIfNotExist(filePath string, storeFunc func() error) error

CreateFileIfNotExist will check whether the file under a certain path 'filePath/fileName' exists, and return an error if it exists, and call the method 'storeFunc' to save the file if it does not exist.

func CreateSubdirInUserHome

func CreateSubdirInUserHome(subdir string) (string, error)

DefaultKpmHome create the '.kpm' in the user home and return the path of ".kpm".

func CreateSymlink(oldName, newName string) error

CreateSymlink will create symbolic link named 'newName' for 'oldName', and if the symbolic link already exists, it will be deleted and recreated.

func DirExists

func DirExists(path string) bool

func Exists

func Exists(path string) (bool, error)

Whether the file exists

func FindKFiles

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

FindKFiles will find all the '.k' files in the 'path' directory.

func GetUsernamePassword

func GetUsernamePassword(usernameOpt string, passwordOpt string, passwordFromStdinOpt bool) (string, string, error)

Copied/Adapted from https://github.com/helm/helm

func HashDir

func HashDir(dir string) (string, error)

HashDir computes the checksum of a directory by concatenating all files and hashing them by sha256.

func JoinPath

func JoinPath(base, elem string) string

JoinPath will join the 'elem' to the 'base' with '/'.

func ParseRepoNameFromGitUrl

func ParseRepoNameFromGitUrl(gitUrl string) string

ParseRepoNameFromGitUrl get the repo name from git url, the repo name in 'https://github.com/xxx/kcl1.git' is 'kcl1'.

func RmNewline

func RmNewline(s string) string

RmNewline will remove all the '\r\n' and '\n' in the string 's'.

func StoreToFile

func StoreToFile(filePath string, dataStr string) error

StoreToFile will store 'data' into toml file under 'filePath'.

func TarDir

func TarDir(srcDir string, tarPath string) error

func UnTarDir

func UnTarDir(tarPath string, destDir string) error

UnTarDir will extract tar from 'tarPath' to 'destDir'.

Types

This section is empty.

Jump to

Keyboard shortcuts

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