utils

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

inspired by a similar library from age, but they don't export functions so we can't just import and re-use them

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandExists

func CommandExists(cmd string) bool

func Compress

func Compress(files []string, buf io.Writer) error

Compress creates a tar.gz of a Directory

func CopyFile

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

CopyFile copies file from src to dst

func DirExists

func DirExists(path string) (bool, error)

func DownloadFile

func DownloadFile(filepath string, url string) error

func GenerateMACAddress

func GenerateMACAddress() (string, error)

GenerateMACAddress

func GenerateRandomAlias

func GenerateRandomAlias() string

func GetImageURL

func GetImageURL(version string) string

func PassphrasePromptForDecryption

func PassphrasePromptForDecryption() (string, error)

func PassphrasePromptForEncryption

func PassphrasePromptForEncryption() (string, error)

func Ping

func Ping(ip string, port string) error

Ping checks if connection is reachable

func Retry

func Retry(attempts int, sleep time.Duration, f func() error) (err error)

Retry retries a function

func StringSliceContains

func StringSliceContains(s []string, e string) bool

StringSliceContains check if string value is in []string

func SupportsHugePages

func SupportsHugePages() (bool, error)

SupportsHugePages

func Uncompress

func Uncompress(source string, destination string) error

Uncompress uncompresses gzip

Types

type CmdResult

type CmdResult struct {
	Name string
	Err  error
}

type Credential

type Credential struct {
	CRType CredentialType
	CR     string
}

func GetCredential

func GetCredential(config string) (Credential, error)

credential backends: raw, env, ssh-agent * if you want to store credentials in the macOS keychain, configure your SSH agent to use the keychain * - raw: "raw::password" (password is a string directly after "raw::" prefix) * - env: "env::PASS_VAR" (password is stored in environment variable $PASS_VAR) * - ssh-agent: "ssh::HOST" (credential is stored in ssh-agent and configured for use with host HOST in the ssh config)

* `ssh-agent` is the most secure by far, as it allows certificate-based authentication rather than using passwords. * If `ssh-agent` is configured and working with certificate-based authentication, `PasswordAuthentication no` can be * set in `/etc/ssh/sshd_config` to significantly harden the VM. * * `env` is more secure than `raw`, and may be useful for automation using macpine on systems where configuring `ssh-agent` * is inconvenient.

type CredentialType

type CredentialType int
const (
	PwdCred CredentialType = iota
	HostCred
)

type PortMap

type PortMap struct {
	Host  int
	Guest int
	Proto Protocol
}

func ParsePort

func ParsePort(ports string) ([]PortMap, error)

Parses port mapping configurations

type Protocol

type Protocol int
const (
	Tcp Protocol = iota
	Udp
)

type WriteCounter

type WriteCounter struct {
	Total uint64
}

func (WriteCounter) PrintProgress

func (wc WriteCounter) PrintProgress()

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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