Documentation ¶
Index ¶
- Constants
- func CheckIfExistsAndIsDirectory(path string) (fs.FileInfo, error)
- func CheckIfExistsAndIsRegular(path string) (fs.FileInfo, error)
- func CopyFile(source, dest string, bufferSize int) error
- func CreateRootFSFile(path string, size int) error
- func EncodePrivateKeyToPEM(privateKey *rsa.PrivateKey) []byte
- func GenerateRSAPrivateKey(bitSize int) (*rsa.PrivateKey, error)
- func GetConfiguredOrSuitableInterfaceName(configured string) (string, error)
- func GetFirstUpBroadcastInterface() (net.Interface, error)
- func GetInterfaceV4Addr(interfaceName string) (addr string, err error)
- func GetSSHKey(privatekey *rsa.PrivateKey) (ssh.PublicKey, error)
- func GetUpBroadcastInterfaces() ([]net.Interface, error)
- func GetenvOrDefault(key, fallback string) string
- func IsValidHostname(host string) bool
- func IsValidTag(input string) bool
- func MarshalSSHPublicKey(key ssh.PublicKey) []byte
- func MkfsExt4(path string) error
- func Mount(file, dir string) error
- func MoveFile(source, target string) error
- func PathExists(path string) (bool, error)
- func RandStringBytes(n int) string
- func RandStringWithDigitsBytes(n int) string
- func RandomHostname() string
- func RunShellCommandNoSudo(command string) (int, error)
- func RunShellCommandSudo(command string) (int, error)
- func SSHPublicKeyFromBytes(b []byte) (ssh.PublicKey, error)
- func SSHPublicKeyFromFile(path string) (ssh.PublicKey, error)
- func TagDecompose(input string) (bool, string, string, string)
- func Umount(dir string) error
- type Defers
Constants ¶
const (
RSABitSize = 4096
)
Defaults
const RootFSCopyBufferSize = 4 * 1024 * 1024
RootFSCopyBufferSize is the buffer size for root file system copy operation.
Variables ¶
This section is empty.
Functions ¶
func CheckIfExistsAndIsDirectory ¶
CheckIfExistsAndIsDirectory checks is a path points at a directory.
func CheckIfExistsAndIsRegular ¶
CheckIfExistsAndIsRegular checks is a path points at a regular file.
func CreateRootFSFile ¶
CreateRootFSFile uses dd to create a rootfs file of given size at a given path.
func EncodePrivateKeyToPEM ¶
func EncodePrivateKeyToPEM(privateKey *rsa.PrivateKey) []byte
EncodePrivateKeyToPEM encodes Private Key from RSA to PEM format.
func GenerateRSAPrivateKey ¶
func GenerateRSAPrivateKey(bitSize int) (*rsa.PrivateKey, error)
GenerateRSAPrivateKey generates a new RSA private key.
func GetConfiguredOrSuitableInterfaceName ¶
GetConfiguredOrSuitableInterfaceName returns the configured interface name, if not empty, or tries retrieving first suitable interface name.
func GetFirstUpBroadcastInterface ¶
GetFirstUpBroadcastInterface retrieves the first suitable up broadact capable interface.
func GetInterfaceV4Addr ¶
GetInterfaceV4Addr fetches an IPv4 address of an interface.
func GetSSHKey ¶
func GetSSHKey(privatekey *rsa.PrivateKey) (ssh.PublicKey, error)
GetSSHKey generates an SSH public key for the given private key.
func GetUpBroadcastInterfaces ¶
GetUpBroadcastInterfaces retrieves the list of up broadcast interfaces. These are internally sorted by an index so the output is always deterministic.
func GetenvOrDefault ¶
GetenvOrDefault calls os>lookup for a key and returns a fallback only if variable wasn't set.
func IsValidHostname ¶
IsValidHostname validates if a string is a valid host name.
func IsValidTag ¶
IsValidTag checks if the given image tag is valid.
func MarshalSSHPublicKey ¶
MarshalSSHPublicKey marshals SSH public key to the OpenSSH format so it can be used for authorized_keys file.
func MoveFile ¶
MoveFile moves file from source to destination. os.Rename does not allow moving between drives hence we have to rewrite the file. Intermediate target directories will be created.
func PathExists ¶
PathExists returns true if path exists.
func RandStringBytes ¶
RandStringBytes returns a random string of length n.
func RandStringWithDigitsBytes ¶
RandStringWithDigitsBytes returns a random string of length n.
func RunShellCommandNoSudo ¶
RunShellCommandNoSudo runs a shell command without sudo.
func RunShellCommandSudo ¶
RunShellCommandSudo runs a shell command with sudo.
func SSHPublicKeyFromBytes ¶
SSHPublicKeyFromBytes reads an SSH public key from bytes.
func SSHPublicKeyFromFile ¶
SSHPublicKeyFromFile reads an SSH public key from a PEM file.
func TagDecompose ¶
TagDecompose decomposes the tag into the image components.
Types ¶
type Defers ¶
type Defers interface { // Add the function to the deferred list of functions. // The new function will be instered at the beginning of the list. Add(func()) // CallAll calls all deferred functions in the reverse order. CallAll() // Calling Trigger(false) causes the instance not to process the defers. Trigger(bool) }
Defers maintains ordered LIFO list of functions to handle on the defer call.