utils

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OSKernel = "taco_os_kernel" // windows, linux, freebsd
	// see https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63#a-list-of-valid-goos-values
	OSFamily     = "taco_os_family"    // darwin, debian, redhat, debian, ”, windows
	OSPlatform   = "taco_os_platform"  // darwin, ubuntu, centos, debian, alpine, windows
	OSName       = "taco_os_name"      // mac os x, ubuntu, centos linux, debian gnu/linux, alpine linux, windows server 2019 standard
	OSVersion    = "taco_os_version"   // 10.15.7, 20.04.1 LTS (Focal Fossa), 8 (Core), 10 (buster), ”, 10.0
	Architecture = "taco_architecture" // x86_64
)

Variables

This section is empty.

Functions

func Chown

func Chown(targetFilePath, userName, groupName string) error

func CloseResourceSecure

func CloseResourceSecure(name string, c io.Closer)

func CopyLocalFile

func CopyLocalFile(sourceFilePath, targetFilePath string, mode os.FileMode) error

func CreateDirPathIfNeeded

func CreateDirPathIfNeeded(targetFilePath string, mode os.FileMode) error

func Decode

func Decode(encodingName string, data []byte) (string, error)

func DetectCharMap

func DetectCharMap(encodingName string) (encoding.Encoding, error)

func Diff

func Diff(expectedStr, actualStr string) string

func DownloadFile

func DownloadFile(ctx context.Context, targetLocation string, sourceURL *url.URL, skipTLSCheck bool) error

func DownloadFtpFile

func DownloadFtpFile(ctx context.Context, u *url.URL, targetFilePath string) error

func DownloadHTTPFile

func DownloadHTTPFile(ctx context.Context, u fmt.Stringer, targetFilePath string) error

func DownloadHTTPSFile

func DownloadHTTPSFile(ctx context.Context, skipTLS bool, u fmt.Stringer, targetFilePath string) error

func Encode

func Encode(encodingName, contentsUtf8 string) ([]byte, error)

func ExtractHashAlgo

func ExtractHashAlgo(hashAlgoName string) (hChecker hash.Hash, err error)

func FileExists

func FileExists(filePath string) (bool, error)

func HashEquals

func HashEquals(hashStr, filePath string) (hashEquals bool, actualCache string, err error)

func HashSum

func HashSum(hashAlgoName, filePath string) (hashSum string, err error)

func MoveFile

func MoveFile(sourceFilePath, targetFilePath string) error

func ParseHashAlgoAndSum

func ParseHashAlgoAndSum(hashStr string) (algoName, sum string, err error)

func ParseLocationOS

func ParseLocationOS(rawLocation string) string

func ReadEncodedFile

func ReadEncodedFile(encodingName, fileName string) (contentsUtf8 string, err error)

func Truncate

func Truncate(data interface{}) string

func WriteEncodedFile

func WriteEncodedFile(encodingName, contentsUtf8, fileName string, perm os.FileMode) error

Types

type CloserFunc

type CloserFunc struct {
	Cf func() error
}

func NewCloserFunc

func NewCloserFunc(f func() error) CloserFunc

func (CloserFunc) Close

func (cf CloserFunc) Close() error

type Errors

type Errors struct {
	Errs []error
}

func (*Errors) Add

func (ve *Errors) Add(err error)

func (Errors) ToError

func (ve Errors) ToError() error

type FsManager

type FsManager struct{}

func (*FsManager) Chmod

func (fmm *FsManager) Chmod(targetFilePath string, mode os.FileMode) error

func (*FsManager) Chown

func (fmm *FsManager) Chown(targetFilePath, userName, groupName string) error

func (*FsManager) CopyLocalFile

func (fmm *FsManager) CopyLocalFile(sourceFilePath, targetFilePath string, mode os.FileMode) error

func (*FsManager) CreateDirPathIfNeeded

func (fmm *FsManager) CreateDirPathIfNeeded(targetFilePath string, mode os.FileMode) error

func (*FsManager) DownloadFile

func (fmm *FsManager) DownloadFile(ctx context.Context, targetLocation string, sourceURL *url.URL, skipTLSCheck bool) error

func (*FsManager) FileExists

func (fmm *FsManager) FileExists(filePath string) (bool, error)

func (*FsManager) MoveFile

func (fmm *FsManager) MoveFile(sourceFilePath, targetFilePath string) error

func (*FsManager) ReadEncodedFile

func (fmm *FsManager) ReadEncodedFile(encodingName, fileName string) (contentsUtf8 string, err error)

func (*FsManager) ReadFile

func (fmm *FsManager) ReadFile(filePath string) (content string, err error)

func (*FsManager) Remove

func (fmm *FsManager) Remove(filePath string) error

func (*FsManager) Stat

func (fmm *FsManager) Stat(name string) (os.FileInfo, error)

func (*FsManager) WriteFile

func (fmm *FsManager) WriteFile(name, contents string, mode os.FileMode) error

type HashManager

type HashManager struct{}

func (HashManager) HashEquals

func (hm HashManager) HashEquals(hashStr, filePath string) (hashEquals bool, actualCache string, err error)

func (HashManager) HashSum

func (hm HashManager) HashSum(hashAlgoName, filePath string) (hashSum string, err error)

type Location

type Location struct {
	IsURL       bool
	URL         *url.URL
	LocalPath   string
	RawLocation string
}

func ParseLocation

func ParseLocation(rawLocation string) Location

type OSDataProvider

type OSDataProvider struct {
}

func (OSDataProvider) GetTemplateVariables

func (odp OSDataProvider) GetTemplateVariables() (map[string]interface{}, error)

Jump to

Keyboard shortcuts

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