util

package
v1.21.9 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupDataDir

func CleanupDataDir(cnf *config.Control)

CleanupDataDir removes the associated "/tmp/k3s/<RANDOM_STRING>" directory along with the 'latest' symlink that points at it.

func ClusterIPNet

func ClusterIPNet() *net.IPNet

func FindStringInCmdAsync

func FindStringInCmdAsync(scanner *bufio.Scanner, target string) bool

func GenerateDataDir

func GenerateDataDir(cnf *config.Control) error

GenerateDataDir creates a temporary directory at "/tmp/k3s/<RANDOM_STRING>/". The latest directory created with this function is soft linked to "/tmp/k3s/latest/". This allows tests to replicate the "/var/lib/rancher/k3s" directory structure.

func GenerateRuntime

func GenerateRuntime(cnf *config.Control) error

GenerateRuntime creates a temporary data dir and configures config.ControlRuntime with all the appropriate certificate keys.

func IsExistingServer

func IsExistingServer() bool

func IsRoot

func IsRoot() bool

IsRoot return true if the user is root (UID 0)

func K3sCmd

func K3sCmd(cmdName string, cmdArgs ...string) (string, error)

K3sCmd launches the provided K3s command via exec. Command blocks until finished. Command output from both Stderr and Stdout is provided via string.

cmdEx1, err := K3sCmd("etcd-snapshot", "ls")
cmdEx2, err := K3sCmd("kubectl", "get", "pods", "-A")

func K3sKillServer

func K3sKillServer(server *K3sServer) error

K3sKillServer terminates the running K3s server and unlocks the file for other tests

func K3sRemoveDataDir

func K3sRemoveDataDir(dataDir string) error

K3sRemoveDataDir removes the provided directory as root

func K3sServerArgs

func K3sServerArgs() []string

K3sServerArgs returns the list of arguments that the k3s server launched with

func ServerArgsPresent

func ServerArgsPresent(neededArgs []string) bool

ServerArgsPresent checks if the given arguments are found in the running k3s server

func ServiceIPNet

func ServiceIPNet() *net.IPNet

Types

type K3sServer

type K3sServer struct {
	// contains filtered or unexported fields
}

func K3sStartServer

func K3sStartServer(inputArgs ...string) (*K3sServer, error)

K3sStartServer acquires an exclusive lock on a temporary file, then launches a k3s cluster with the provided arguments. Subsequent/parallel calls to this function will block until the original lock is cleared using K3sKillServer

Jump to

Keyboard shortcuts

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