kubectl

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 11 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

type CLI struct {
	KubeContext string
	KubeConfig  string
	Namespace   string
	// contains filtered or unexported fields
}

CLI holds parameters to run kubectl.

func NewCLI

func NewCLI(cfg Config, defaultNamespace string) *CLI

NewCLI creates a new kubectl CLI whereby the namespace from command line / environment variable takes precedence over "default namespace" defined in deployer configuration

func (*CLI) CheckVersion

func (c *CLI) CheckVersion(ctx context.Context) error

CheckVersion warns the user if their kubectl version is < 1.12.0

func (*CLI) Command

func (c *CLI) Command(ctx context.Context, command string, arg ...string) *exec.Cmd

Command creates the underlying exec.CommandContext. This allows low-level control of the executed command.

func (*CLI) CommandWithNamespaceArg

func (c *CLI) CommandWithNamespaceArg(ctx context.Context, command string, namespace string, arg ...string) *exec.Cmd

Command creates the underlying exec.CommandContext with namespace. This allows low-level control of the executed command.

func (*CLI) CommandWithStrictCancellation

func (c *CLI) CommandWithStrictCancellation(ctx context.Context, command string, arg ...string) *Cmd

CommandWithStrictCancellation ensures for windows OS that all child process get terminated on cancellation

func (*CLI) CommandWithoutNamespaceArg added in v2.3.1

func (c *CLI) CommandWithoutNamespaceArg(ctx context.Context, command string, arg ...string) *exec.Cmd

Command creates the underlying exec.CommandContext without a namespace. This allows low-level control of the executed command.

func (*CLI) CompareVersionTo

func (c *CLI) CompareVersionTo(ctx context.Context, vMajor, vMinor int) (int, error)

func (*CLI) Kustomize

func (c *CLI) Kustomize(ctx context.Context, args []string) ([]byte, error)

Kustomize runs `kubectl kustomize` with the provided args

func (*CLI) Run

func (c *CLI) Run(ctx context.Context, in io.Reader, out io.Writer, command string, arg ...string) error

Run shells out kubectl CLI.

func (*CLI) RunInNamespace

func (c *CLI) RunInNamespace(ctx context.Context, in io.Reader, out io.Writer, command string, namespace string, arg ...string) error

RunInNamespace shells out kubectl CLI with given namespace

func (*CLI) RunOut

func (c *CLI) RunOut(ctx context.Context, command string, arg ...string) ([]byte, error)

RunOut shells out kubectl CLI.

func (*CLI) RunOutInput

func (c *CLI) RunOutInput(ctx context.Context, in io.Reader, command string, arg ...string) ([]byte, error)

RunOutInput shells out kubectl CLI with a given input stream.

func (*CLI) RunOutWithoutNamespace added in v2.3.1

func (c *CLI) RunOutWithoutNamespace(ctx context.Context, command string, arg ...string) ([]byte, error)

RunInNamespace shells out kubectl CLI with given namespace

func (*CLI) Version

func (c *CLI) Version(ctx context.Context) ClientVersion

Version returns the client version of kubectl.

type ClientVersion

type ClientVersion struct {
	Major string `json:"major"`
	Minor string `json:"minor"`
}

ClientVersion is the client version of kubectl.

func (ClientVersion) String

func (v ClientVersion) String() string

type Cmd

type Cmd struct {
	*exec.Cmd
}

Cmd is a wrapper on exec.Cmd

func CommandContext

func CommandContext(ctx context.Context, name string, arg ...string) *Cmd

CommandContext creates a new Cmd

func (*Cmd) Terminate

func (c *Cmd) Terminate() error

Terminate kills the underlying process

type Config

type Config interface {
	GetKubeContext() string
	GetKubeConfig() string
	GetKubeNamespace() string
}

type Version

type Version struct {
	Client ClientVersion `json:"clientVersion"`
}

Version is the client version of kubectl.

Jump to

Keyboard shortcuts

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