kubectl

package
v0.3.44 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package kubectl executes various kubectl sub-commands in a forked shell

Package kubectl executes various kubectl sub-commands in a forked shell

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyCommand

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

ApplyCommand is a Kubectl sub-command that recursively applies all the YAML files it finds in a directory.

func (*ApplyCommand) Build

func (c *ApplyCommand) Build() (buildDir string)

Build executes the Kustomize command with all its arguments and returns the output.

func (*ApplyCommand) DryRun

func (c *ApplyCommand) DryRun() (output []byte, err error)

DryRun executes the Kubectl command as a dry run and returns the output without making any changes to the cluster.

func (*ApplyCommand) Run

func (c *ApplyCommand) Run() (output []byte, err error)

Run executes the Kubectl command with all its arguments and returns the output.

func (*ApplyCommand) WithLogger

func (c *ApplyCommand) WithLogger(logger logr.Logger) (self Command)

WithLogger sets the Logger the command should use to log actions if passed a Logger that is not nil.

type BuildCommand

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

BuildCommand is a kustomize sub-command that processes a kustomization.yaml file.

func (*BuildCommand) Build

func (c *BuildCommand) Build() (buildDir string)

Build executes the Kustomize command with all its arguments and returns the output.

func (*BuildCommand) DryRun

func (c *BuildCommand) DryRun() (output []byte, err error)

DryRun executes the Kubectl command as a dry run and returns the output without making any changes to the cluster.

func (*BuildCommand) Run

func (c *BuildCommand) Run() (output []byte, err error)

Run executes the Kubectl command with all its arguments and returns the output.

func (*BuildCommand) WithLogger

func (c *BuildCommand) WithLogger(logger logr.Logger) (self Command)

WithLogger sets the Logger the command should use to log actions if passed a Logger that is not nil.

type Command

type Command interface {
	Run() (output []byte, err error)
	Build() (buildDir string)
	DryRun() (output []byte, err error)
	WithLogger(logger logr.Logger) (self Command)
	// contains filtered or unexported methods
}

Command defines an interface for commands created by the Kubectl factory type.

type CommandFactory

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

CommandFactory is a concrete Factory implementation of the Kubectl interface's API.

func (*CommandFactory) Apply

func (f *CommandFactory) Apply(path string) (c Command)

Apply instantiates an ApplyCommand instance using the provided directory path.

func (*CommandFactory) Build

func (f *CommandFactory) Build(path string) (c Command)

Build instantiates an BuildCommand instance using the provided directory path.

func (*CommandFactory) Delete

func (f *CommandFactory) Delete(args ...string) (c Command)

Delete instantiates a DeleteCommand instance for the described Kubernetes resource.

func (*CommandFactory) Get

func (f *CommandFactory) Get(args ...string) (c Command)

Get instantiates a GetCommand instance for the described Kubernetes resource

type DeleteCommand

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

DeleteCommand implements the Command interface to delete resources from the KubeAPI service.

func (*DeleteCommand) Build

func (c *DeleteCommand) Build() (buildDir string)

Build executes the Kustomize command with all its arguments and returns the output.

func (*DeleteCommand) DryRun

func (c *DeleteCommand) DryRun() (output []byte, err error)

DryRun executes the Kubectl command as a dry run and returns the output without making any changes to the cluster.

func (*DeleteCommand) Run

func (c *DeleteCommand) Run() (output []byte, err error)

Run executes the Kubectl command with all its arguments and returns the output.

func (*DeleteCommand) WithLogger

func (c *DeleteCommand) WithLogger(logger logr.Logger) (self Command)

WithLogger sets the Logger the command should use to log actions if passed a Logger that is not nil.

type ExecProvider

type ExecProvider interface {
	FileExists(filePath string) bool
	FindOnPath(file string) (string, error)
	ExecCmd(name string, arg ...string) ([]byte, error)
}

ExecProvider interface defines functions Kubectl uses to verify and execute a local command.

type GetCommand

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

GetCommand implements the Command interface to delete resources from the KubeAPI service

func (*GetCommand) Build

func (c *GetCommand) Build() (buildDir string)

Build executes the Kustomize command with all its arguments and returns the output.

func (*GetCommand) DryRun

func (c *GetCommand) DryRun() (output []byte, err error)

DryRun executes the Kubectl command as a dry run and returns the output without making any changes to the cluster.

func (*GetCommand) Run

func (c *GetCommand) Run() (output []byte, err error)

Run executes the Kubectl command with all its arguments and returns the output.

func (*GetCommand) WithLogger

func (c *GetCommand) WithLogger(logger logr.Logger) (self Command)

WithLogger sets the Logger the command should use to log actions if passed a Logger that is not nil.

type Kubectl

type Kubectl interface {
	Apply(path string) (c Command)
	Delete(args ...string) (c Command)
	Get(args ...string) (c Command)
}

Kubectl is a Factory interface that returns concrete Command implementations from named constructors.

func NewKubectl

func NewKubectl(logger logr.Logger) (kubectl Kubectl, err error)

NewKubectl returns a Kubectl object for creating and running kubectl sub-commands.

type Kustomize

type Kustomize interface {
	Build(path string) (c Command)
}

Kustomize is a Factory interface that returns concrete Command implementations from named constructors.

func NewKustomize

func NewKustomize(logger logr.Logger) (kustomize Kustomize, err error)

NewKustomize returns a Kustomize object for creating and running Kustomize sub-commands.

Jump to

Keyboard shortcuts

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