kubeutil

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKubeConfigPath

func GetKubeConfigPath() (string, error)

func NodeNameFromHost

func NodeNameFromHost(kubectl *Kubectl, host string) (string, error)

Get the name by which the cluster recognizes a given host.

Types

type ExecKubectlFunc

type ExecKubectlFunc func(kubectl *Kubectl, args ...string) error
var ExecKubectl ExecKubectlFunc = func(kubectl *Kubectl, args ...string) error {
	osCmd := exec.Command("kubectl", args...)
	osCmd.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", kubectl.KubeconfigPath))
	osCmd.Stdin = os.Stdin
	osCmd.Stdout = os.Stdout
	osCmd.Stderr = os.Stderr

	return osCmd.Run()
}

type GetInKubectlFunc

type GetInKubectlFunc func(kubectl *Kubectl, stdin string, args ...string) (string, error)
var GetInKubectl GetInKubectlFunc = func(kubectl *Kubectl, stdin string, args ...string) (string, error) {
	osCmd := exec.Command("kubectl", args...)
	osCmd.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", kubectl.KubeconfigPath))
	osCmd.Stdin = strings.NewReader(stdin)
	osCmd.Stderr = os.Stderr

	outputBytes, err := osCmd.Output()
	return string(outputBytes), err
}

type GetKubectlFunc

type GetKubectlFunc func(kubectl *Kubectl, args ...string) (string, error)
var GetKubectl GetKubectlFunc = func(kubectl *Kubectl, args ...string) (string, error) {
	osCmd := exec.Command("kubectl", args...)
	osCmd.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", kubectl.KubeconfigPath))
	osCmd.Stdin = os.Stdin
	osCmd.Stderr = os.Stderr

	outputBytes, err := osCmd.Output()
	return string(outputBytes), err
}

type InKubectlFunc

type InKubectlFunc func(kubectl *Kubectl, stdin string, args ...string) error
var InKubectl InKubectlFunc = func(kubectl *Kubectl, stdin string, args ...string) error {
	osCmd := exec.Command("kubectl", args...)
	osCmd.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", kubectl.KubeconfigPath))
	osCmd.Stdin = strings.NewReader(stdin)
	osCmd.Stdout = os.Stdout
	osCmd.Stderr = os.Stderr

	return osCmd.Run()
}

type Kubectl

type Kubectl struct {
	KubeconfigPath string
}

Kubectl struct allows for execution of a kubectl command with a non-environment set kubeconfig path. TODO: Move more uses of kubeutil.ExecKubectl/GetKubectl/etc to use this structure.

func NewKubectl

func NewKubectl(kubeconfigPath string) *Kubectl

func NewKubectlFromNode added in v0.12.0

func NewKubectlFromNode(host string) (*Kubectl, error)

func (*Kubectl) Destroy

func (kubectl *Kubectl) Destroy() error

Jump to

Keyboard shortcuts

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