alfredo

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

README

alfredo

golang modules for various things

Documentation

Index

Constants

View Source
const (
	ALFREDO_VERSION = "23Oct2023 - 2000"
	NOT_AVAILABLE   = "N/A"
)

Variables

This section is empty.

Functions

func BlankIsNA added in v0.2.0

func BlankIsNA(s string) string

func CSVtoArray

func CSVtoArray(tagcsv string) []string

func CopyFile added in v0.2.0

func CopyFile(src, dst string) (int64, error)

func DmidecodeProduct

func DmidecodeProduct() (string, error)

func EmptyString

func EmptyString(s string) bool

func Error2ExitCode

func Error2ExitCode(err error) int

func ExecToFile

func ExecToFile(cli string, ofile string) (err error)

func FileExists

func FileExists(filename string) (bool, error)

func FileExistsEasy

func FileExistsEasy(p string) bool

func GetFirstFile

func GetFirstFile(rootpath string, hint string) string

func GetPrivateSSHKey

func GetPrivateSSHKey() string

func Grep

func Grep(path string, musthave string, mustnothave string) ([]string, error)

was "readlines"

func Gunzip

func Gunzip(dst string, r io.Reader) error

Untar takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dst' along the way, and writing any files

func HighLight

func HighLight(a string, b string, hl string) string

func Hostname

func Hostname() (string, error)

func HumanReadableBigNumber

func HumanReadableBigNumber(n int64) string

func HumanReadableSeconds

func HumanReadableSeconds(s int64) string

func HumanReadableStorageCapacity

func HumanReadableStorageCapacity(b int64) string

func IsMonth

func IsMonth(m string) bool

simple test of a 3 character string; month or not a month; Not locale friendly!

func LoadFileIntoSlice

func LoadFileIntoSlice(f string) ([]string, error)

load a file with lines that \n terminated into a slice (used by the syslog self-test)

func MD5sumChunk

func MD5sumChunk(filePath string, chunkSize int64)

work in progress; want to return string of hash for a partial file

func MD5sumFile

func MD5sumFile(filePath string) (string, error)

func Move

func Move(src, dst string) error

func NotBlankIsMasked added in v0.2.0

func NotBlankIsMasked(s string) string

func Popen3

func Popen3(output_buffer *bytes.Buffer, stack ...*exec.Cmd) (err error)

formerly Execute

func Popen3Grep

func Popen3Grep(cmd string, musthave string, mustnothave string) ([]string, error)

func Popen3GrepFast

func Popen3GrepFast(cmd string, musthave string, mustnothave string) ([]string, error)

func PopentoString

func PopentoString(cmd string) (string, error)

func PopentoStringAwk

func PopentoStringAwk(cmd string, awk int) (string, error)

func PrettyPrint

func PrettyPrint(v any) string

generate a "prettyprint" output of the structure

func ReadFileToSlice

func ReadFileToSlice(filename string, force bool) ([]string, error)

func ReadStructFromCommand

func ReadStructFromCommand(cli string, structure interface{}) error

func ReadStructFromCommandOverSSH

func ReadStructFromCommandOverSSH(ssh SSHStruct, cli string, structure interface{}) error

func ReadStructFromJSONFile

func ReadStructFromJSONFile(filePath string, structure interface{}) error

simply reads JSON data from a file and populates the provided structure.

func ReadStructFromString

func ReadStructFromString(content string, structure interface{}) error

func RecursiveDelete

func RecursiveDelete(path string) error

func RemoveFile

func RemoveFile(path string) error

func RemoveGlob

func RemoveGlob(glob string) error

func RemoveTag added in v0.2.0

func RemoveTag(l []string, s string) []string

func SSHPopenToString

func SSHPopenToString(hostname string, command string) (string, error)

func SetEnvironment

func SetEnvironment(v *bool, env_var string)

func SetPrivateSSHKey

func SetPrivateSSHKey(newkey string)

func SetStringIfNotSet added in v0.2.0

func SetStringIfNotSet(v string, d string) string

func SetVerbose

func SetVerbose(v bool)

func SliceContains

func SliceContains(haystack []string, needle string) bool

func Spinny

func Spinny(sigChan chan bool)

func StringToFileOverSSH

func StringToFileOverSSH(outputContent string, remoteserver string, outputfile string) error

write otuput content (including new lines) to file outputfile (including full absolute path) on remoteserver over SSH

func System3

func System3(cmd string) error

func System3AndSpin

func System3AndSpin(cmd string, redirect string) (err error)

func System3toCapturedString added in v0.2.0

func System3toCapturedString(s *string, cmd string) error

func Targz

func Targz(sourceDir string, outputFilename string, leaveout string) error

func Touch

func Touch(fileName string) error

func TrimQuotes

func TrimQuotes(s string) string

func TrimSuffix

func TrimSuffix(s, suffix string) string

func TrueIsYes

func TrueIsYes(b bool) string

func UniqTagSet added in v0.2.0

func UniqTagSet(l []string) []string

func Untar

func Untar(dst string, r io.Reader) error

Untar takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dst' along the way, and writing any files

func Unzip

func Unzip(destination string, r *zip.ReadCloser) error

Untar takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dst' along the way, and writing any files

func VerbosePrintln

func VerbosePrintln(cmd string)

for debugging purposes, a more verbose output to catch attention

func WriteSliceToFile

func WriteSliceToFile(filename string, content []string) error

func WriteSparseFile

func WriteSparseFile(f string, sizeMin int, sizeMax int, r int) error

write a sparse file f of size, randomly between sizeMin and sizeMax, r random 1's in the 0's. Seek for 0's

func WriteStringToFile

func WriteStringToFile(filename string, content string) error

func WriteStructToJSONFile

func WriteStructToJSONFile(filePath string, structure interface{}) error

simply write a data interface to a json file; shamelessly picked off the internet

Types

type ExecCallBackFunc added in v0.2.0

type ExecCallBackFunc func(*string, string) error

type ExecStruct added in v0.2.0

type ExecStruct struct {
	SpinSigChan  chan bool
	WatchSigChan chan bool
	ErrChan      chan error
	// contains filtered or unexported fields
}

func (*ExecStruct) Execute added in v0.2.0

func (ex *ExecStruct) Execute() error

func (ExecStruct) GetIface added in v0.2.0

func (ex ExecStruct) GetIface() interface{}

func (ExecStruct) Init added in v0.2.0

func (ex ExecStruct) Init() ExecStruct

func (ExecStruct) OkToSpin added in v0.2.0

func (ex ExecStruct) OkToSpin() bool

func (ExecStruct) OkToWatch added in v0.2.0

func (ex ExecStruct) OkToWatch() bool

func (ExecStruct) WithCapture added in v0.2.0

func (ex ExecStruct) WithCapture(c bool) ExecStruct

func (ExecStruct) WithDirectory added in v0.2.0

func (ex ExecStruct) WithDirectory(d string) ExecStruct

func (ExecStruct) WithHintInterface added in v0.2.0

func (ex ExecStruct) WithHintInterface(i interface{}) ExecStruct

func (ExecStruct) WithMainExecFunc added in v0.2.0

func (ex ExecStruct) WithMainExecFunc(cb ExecCallBackFunc, cli string) ExecStruct

func (ExecStruct) WithProgressExecFunc added in v0.2.0

func (ex ExecStruct) WithProgressExecFunc(cb ProgressCallBackFunc) ExecStruct

func (ExecStruct) WithSSH added in v0.2.0

func (ex ExecStruct) WithSSH(ssh SSHStruct, cli string) ExecStruct

func (ExecStruct) WithSpinny added in v0.2.0

func (ex ExecStruct) WithSpinny(b bool) ExecStruct

func (ExecStruct) WithWatcherExecFunc added in v0.2.0

func (ex ExecStruct) WithWatcherExecFunc(cb WatcherCallBackFunc) ExecStruct

type ProgressCallBackFunc added in v0.2.0

type ProgressCallBackFunc func(chan bool)

type S3ClientSession added in v0.2.0

type S3ClientSession struct {
	Credentials S3credStruct `json:"s3creds"`
	Bucket      string
	Endpoint    string
	Region      string
	Client      *s3.S3
	Versioning  bool
	// contains filtered or unexported fields
}

func (S3ClientSession) CreateBucket added in v0.2.0

func (this S3ClientSession) CreateBucket() error

func (S3ClientSession) EstablishSession added in v0.2.0

func (this S3ClientSession) EstablishSession() S3ClientSession

func (S3ClientSession) HeadBucket added in v0.2.0

func (this S3ClientSession) HeadBucket() (bool, error)

func (S3ClientSession) KeepBucket added in v0.2.0

func (s3c S3ClientSession) KeepBucket() S3ClientSession

func (S3ClientSession) RecursiveBucketDelete added in v0.2.0

func (this S3ClientSession) RecursiveBucketDelete() error

func (S3ClientSession) RemoveBucket added in v0.2.0

func (this S3ClientSession) RemoveBucket() error

func (S3ClientSession) SetBucket added in v0.2.0

func (this S3ClientSession) SetBucket(b string) S3ClientSession

func (S3ClientSession) SetEndpoint added in v0.2.0

func (this S3ClientSession) SetEndpoint(sep string) S3ClientSession

func (S3ClientSession) SetRegion added in v0.2.0

func (this S3ClientSession) SetRegion(r string) S3ClientSession

func (S3ClientSession) SetVersioning added in v0.2.0

func (this S3ClientSession) SetVersioning(v bool) S3ClientSession

func (S3ClientSession) Sync added in v0.2.0

func (this S3ClientSession) Sync(localPath string) error

func (S3ClientSession) SyncInner added in v0.2.0

func (this S3ClientSession) SyncInner(trimsz int, localPath string) error

type S3credStruct added in v0.2.0

type S3credStruct struct {
	AccessKey  string `json:"accessKey"`
	Active     bool   `json:"active"`
	CreateDate int64  `json:"createDate"`
	ExpireDate int64  `json:"expireDate"`
	SecretKey  string `json:"secretKey"`
	Profile    string `json:"profile"`
}

func (S3credStruct) CredentialsStanza added in v0.2.0

func (s3c S3credStruct) CredentialsStanza() string

func (S3credStruct) GenerateAWSCLItoString added in v0.2.0

func (s3c S3credStruct) GenerateAWSCLItoString(endpoint string, region string, useSSL bool) string

type SSHStruct

type SSHStruct struct {
	Key  string `json:"key"`
	User string `json:"user"`
	Host string `json:"host"`
	// contains filtered or unexported fields
}

func (SSHStruct) BackgroundedRemoteExecute

func (s SSHStruct) BackgroundedRemoteExecute(cli string) (SSHStruct, error)

func (SSHStruct) Chown added in v0.2.0

func (s SSHStruct) Chown(uid int, gid int, path string) error

func (SSHStruct) DownloadCLI

func (s SSHStruct) DownloadCLI(src string, tgt string) string

remote, local

func (SSHStruct) GetBody added in v0.2.0

func (s SSHStruct) GetBody() string

func (SSHStruct) GetRemoteDir added in v0.2.0

func (s SSHStruct) GetRemoteDir() string

func (SSHStruct) GetRemoteHostname

func (s SSHStruct) GetRemoteHostname() (string, error)

func (SSHStruct) GetSSHCli

func (s SSHStruct) GetSSHCli() string

func (SSHStruct) MkdirAll added in v0.2.0

func (s SSHStruct) MkdirAll(dir string) error

func (SSHStruct) RemoteExecuteAndSpin

func (this SSHStruct) RemoteExecuteAndSpin(cli string) (SSHStruct, error)

func (SSHStruct) RemoteFileExists

func (s SSHStruct) RemoteFileExists(path string) bool

return false on error or file doesn't exist (easy mode)

func (SSHStruct) SecureDownload

func (this SSHStruct) SecureDownload(remoteFilePath string, localFilePath string) error

func (SSHStruct) SecureDownloadAndSpin

func (this SSHStruct) SecureDownloadAndSpin(remoteFilePath string, localFilePath string) error

func (*SSHStruct) SecureRemoteExecution

func (this *SSHStruct) SecureRemoteExecution(cli string) error

func (SSHStruct) SecureUpload

func (this SSHStruct) SecureUpload(localFilePath string, remoteFilePath string) error

func (SSHStruct) SecureUploadAndSpin

func (this SSHStruct) SecureUploadAndSpin(localFilePath string, remoteFilePath string) error

func (*SSHStruct) SetCapture added in v0.2.0

func (s *SSHStruct) SetCapture(c bool) SSHStruct

func (*SSHStruct) SetDefaults

func (this *SSHStruct) SetDefaults()

func (*SSHStruct) SetHost added in v0.2.0

func (s *SSHStruct) SetHost(h string) SSHStruct

func (SSHStruct) UploadCLI

func (this SSHStruct) UploadCLI(src string, tgt string) string

local, remote

func (SSHStruct) WithCapture added in v0.2.0

func (s SSHStruct) WithCapture(c bool) SSHStruct

func (SSHStruct) WithHost added in v0.2.0

func (s SSHStruct) WithHost(h string) SSHStruct

func (SSHStruct) WithKey added in v0.2.0

func (s SSHStruct) WithKey(k string) SSHStruct

func (SSHStruct) WithRemoteDir added in v0.2.0

func (s SSHStruct) WithRemoteDir(rd string) SSHStruct

func (SSHStruct) WithSilent added in v0.2.0

func (s SSHStruct) WithSilent(c bool) SSHStruct

func (SSHStruct) WithUser added in v0.2.0

func (s SSHStruct) WithUser(u string) SSHStruct

type WatcherCallBackFunc added in v0.2.0

type WatcherCallBackFunc func(*ExecStruct) error

Jump to

Keyboard shortcuts

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