utils

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNonEmptyLines

func GetNonEmptyLines(output string) []string

GetNonEmptyLines converts given command output string into individual objects according to line breakers, and ignores the empty elements in it.

func InsertCode

func InsertCode(filename, target, code string) error

InsertCode searches target content in the file and insert `toInsert` after the target.

func UncommentCode

func UncommentCode(filename, target, prefix string) error

UncommentCode searches for target in the file and remove the comment prefix of the target content. The target content may span multiple lines.

Types

type CmdContext

type CmdContext struct {
	// environment variables in k=v format.
	Env   []string
	Dir   string
	Stdin io.Reader
}

CmdContext provides context for command execution

func (*CmdContext) Run

func (cc *CmdContext) Run(cmd *exec.Cmd) ([]byte, error)

Run executes the provided command within this context

type KBTestContext

type KBTestContext struct {
	*CmdContext
	TestSuffix string
	Domain     string
	Group      string
	Version    string
	Kind       string
	Resources  string
	ImageName  string
	Kubectl    *Kubectl
}

KBTestContext specified to run e2e tests

func TestContext

func TestContext(env ...string) (*KBTestContext, error)

TestContext init with a random suffix for test KBTestContext stuff, to avoid conflict when running tests synchronously.

func (*KBTestContext) CleanupManifests

func (kc *KBTestContext) CleanupManifests(dir string)

CleanupManifests is a helper func to run kustomize build and pipe the output to kubectl delete -f -

func (*KBTestContext) CreateAPI

func (kc *KBTestContext) CreateAPI(resourceOptions ...string) error

CreateAPI is for running `kubebuilder create api`

func (*KBTestContext) CreateWebhook

func (kc *KBTestContext) CreateWebhook(resourceOptions ...string) error

CreateWebhook is for running `kubebuilder create webhook`

func (*KBTestContext) Destroy

func (kc *KBTestContext) Destroy()

Destroy is for cleaning up the docker images for testing

func (*KBTestContext) Init

func (kc *KBTestContext) Init(initOptions ...string) error

Init is for running `kubebuilder init`

func (*KBTestContext) InstallCertManager

func (kc *KBTestContext) InstallCertManager() error

InstallCertManager installs the cert manager bundle.

func (*KBTestContext) InstallPrometheusOperManager

func (kc *KBTestContext) InstallPrometheusOperManager() error

InstallPrometheusOperManager installs the prometheus manager bundle.

func (*KBTestContext) LoadImageToKindCluster

func (kc *KBTestContext) LoadImageToKindCluster() error

LoadImageToKindCluster loads a local docker image to the kind cluster

func (*KBTestContext) Make

func (kc *KBTestContext) Make(makeOptions ...string) error

Make is for running `make` with various targets

func (*KBTestContext) Prepare

func (kc *KBTestContext) Prepare() error

Prepare prepare a work directory for testing

func (*KBTestContext) UninstallCertManager

func (kc *KBTestContext) UninstallCertManager()

UninstallCertManager uninstalls the cert manager bundle.

func (*KBTestContext) UninstallPrometheusOperManager

func (kc *KBTestContext) UninstallPrometheusOperManager()

UninstallPrometheusOperManager uninstalls the prometheus manager bundle.

type Kubectl

type Kubectl struct {
	*CmdContext
	Namespace string
}

Kubectl contains context to run kubectl commands

func (*Kubectl) Apply

func (k *Kubectl) Apply(inNamespace bool, cmdOptions ...string) (string, error)

Apply is a general func to run kubectl apply commands

func (*Kubectl) Command

func (k *Kubectl) Command(cmdOptions ...string) (string, error)

Command is a general func to run kubectl commands

func (*Kubectl) CommandInNamespace

func (k *Kubectl) CommandInNamespace(cmdOptions ...string) (string, error)

CommandInNamespace is a general func to run kubectl commands in the namespace

func (*Kubectl) Delete

func (k *Kubectl) Delete(inNamespace bool, cmdOptions ...string) (string, error)

Delete is a func to run kubectl delete commands

func (*Kubectl) Get

func (k *Kubectl) Get(inNamespace bool, cmdOptions ...string) (string, error)

Get is a func to run kubectl get commands

func (*Kubectl) Logs

func (k *Kubectl) Logs(cmdOptions ...string) (string, error)

Logs is a func to run kubectl logs commands

func (*Kubectl) WithInput

func (k *Kubectl) WithInput(stdinInput string) *Kubectl

WithInput is a general func to run kubectl commands with input

Jump to

Keyboard shortcuts

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