util

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildKubernetesClientset

func BuildKubernetesClientset(ctx *Context) error

BuildKubernetesClientset builds core kubernetes and apiextensions clientsets

func DownloadKubeconfig

func DownloadKubeconfig(cluster *config.Cluster) ([]byte, error)

DownloadKubeconfig downloads Kubeconfig over SSH

func HackIssue321InitDynamicClient added in v0.4.0

func HackIssue321InitDynamicClient(ctx *Context) error

HackIssue321InitDynamicClient initialize controller-runtime/client name comes from: https://github.com/kubernetes-sigs/controller-runtime/issues/321

func IsRunning

func IsRunning(stdout string) bool

IsRunning checks if the given output represents the "Running" status of a Kubernetes pod.

func MakeShellCommand

func MakeShellCommand(cmd string, variables TemplateVariables) (string, error)

MakeShellCommand render text template with given `variables` render-context

Types

type Configuration

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

Configuration holds a map of generated files

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration constructor

func (*Configuration) AddFile

func (c *Configuration) AddFile(filename string, content string)

AddFile save file contents for future references

func (*Configuration) Backup

func (c *Configuration) Backup(target string) error

Backup dumps the files into a .tar.gz archive.

func (*Configuration) Debug

func (c *Configuration) Debug()

Debug list filenames and their size to the standard output

func (*Configuration) Download

func (c *Configuration) Download(conn ssh.Connection, source string, prefix string) error

Download a files matching `source` pattern

func (*Configuration) Get

func (c *Configuration) Get(filename string) (string, error)

Get returns contents of the generated file by filename

func (*Configuration) UploadTo

func (c *Configuration) UploadTo(conn ssh.Connection, directory string) error

UploadTo directory all the files

type Context

type Context struct {
	Cluster                   *config.Cluster
	Logger                    logrus.FieldLogger
	Connector                 *ssh.Connector
	Configuration             *Configuration
	Runner                    *Runner
	WorkDir                   string
	JoinCommand               string
	JoinToken                 string
	RESTConfig                *rest.Config
	DynamicClient             dynclient.Client
	Verbose                   bool
	BackupFile                string
	DestroyWorkers            bool
	ForceUpgrade              bool
	UpgradeMachineDeployments bool
}

Context hold together currently test flags and parsed info, along with utilities like logger

func (*Context) Clone

func (c *Context) Clone() *Context

Clone returns a shallow copy of the context.

func (*Context) RunTaskOnAllNodes

func (c *Context) RunTaskOnAllNodes(task NodeTask, parallel bool) error

RunTaskOnAllNodes runs the given task on all hosts.

func (*Context) RunTaskOnFollowers

func (c *Context) RunTaskOnFollowers(task NodeTask, parallel bool) error

RunTaskOnFollowers runs the given task on the follower hosts.

func (*Context) RunTaskOnLeader

func (c *Context) RunTaskOnLeader(task NodeTask) error

RunTaskOnLeader runs the given task on the leader host.

func (*Context) RunTaskOnNodes

func (c *Context) RunTaskOnNodes(nodes []*config.HostConfig, task NodeTask, parallel bool) error

RunTaskOnNodes runs the given task on the given selection of hosts.

type NodeTask

type NodeTask func(ctx *Context, node *config.HostConfig, conn ssh.Connection) error

NodeTask is a task that is specifically tailored to run on a single node.

type Runner

type Runner struct {
	Conn    ssh.Connection
	Prefix  string
	OS      string
	Verbose bool
}

Runner bundles a connection to a host with the verbosity and other options for running commands via SSH.

func (*Runner) Run

func (r *Runner) Run(cmd string, variables TemplateVariables) (string, string, error)

Run executes a given command/script, optionally printing its output to stdout/stderr.

func (*Runner) WaitForCondition

func (r *Runner) WaitForCondition(cmd string, timeout time.Duration, validator validatorFunc) bool

WaitForCondition waits for something to be true.

func (*Runner) WaitForPod

func (r *Runner) WaitForPod(namespace string, name string, timeout time.Duration) error

WaitForPod waits for the availability of the given Kubernetes element.

type Tee

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

Tee mimics the unix `tee` command by piping its input through to the upstream writer and also capturing it in a buffer.

func NewTee

func NewTee(wc io.WriteCloser) *Tee

NewTee constructor

func (*Tee) Close

func (t *Tee) Close() error

Close underlying io.Closer

func (*Tee) String

func (t *Tee) String() string

func (*Tee) Write

func (t *Tee) Write(p []byte) (int, error)

type TemplateVariables

type TemplateVariables map[string]interface{}

TemplateVariables is a render context for templates

Jump to

Keyboard shortcuts

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