kubernetes

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfig

func NewConfig(kubeConfig string) (*rest.Config, error)

NewConfig returns a new rest.Config instance based on the kubeconfig path provided. If the path is blank, an in-cluster configuration is assumed.

Types

type KubeConfigApplier

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

The KubeConfigApplier type applies YAML-encoded Kubernetes resources directly using the Kubernetes API.

func NewKubeConfigApplier

func NewKubeConfigApplier(kubeConfig string) (*KubeConfigApplier, error)

NewKubeConfigApplier returns a new instance of the KubeConfigApplier type that connects to a Kubernetes API server via the provided kubeconfig file location. If the provided location is blank, an in-cluster configuration is assumed.

func (*KubeConfigApplier) Apply

func (k *KubeConfigApplier) Apply(ctx context.Context, r io.Reader) error

Apply the contents of the io.Reader implementation to the Kubernetes cluster described in the kubeconfig file. Any resources that already exist will be patched. It is assumed that the contents of the io.Reader implementation will be a YAML stream of Kubernetes resources separated by "---". The Apply operation can be cancelled via the provided context.Context.

type ObjectCallback

type ObjectCallback func(ctx context.Context, object *unstructured.Unstructured) error

The ObjectCallback type is a function that is invoked for each Kubernetes object parsed when calling ObjectScanner.Apply.

type ObjectScanner

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

The ObjectScanner type is used to parse a YAML stream of Kubernetes resources and invoke a callback for each one.

func NewObjectScanner

func NewObjectScanner(r io.Reader) *ObjectScanner

NewObjectScanner returns a new instance of the ObjectScanner type that will parse the provided io.Reader's data as a YAML-encoded stream of Kubernetes resources.

func (*ObjectScanner) ForEach

func (oj *ObjectScanner) ForEach(ctx context.Context, fn ObjectCallback) error

ForEach iterates through the stream of YAML-encoded Kubernetes resources and invokes the ObjectCallback for each one. Iteration can be cancelled by the ObjectCallback returning a non-nil error or by cancelling the provided context.Context.

type StdOutApplier

type StdOutApplier struct{}

The StdOutApplier type applies YAML-encoded Kubernetes resources by writing them to os.Stdout.

func NewStdOutApplier

func NewStdOutApplier() *StdOutApplier

NewStdOutApplier returns a new instance of the StdOutApplier type that will Apply YAML-encoded Kubernetes resources by writing them to os.Stdout

func (*StdOutApplier) Apply

func (s *StdOutApplier) Apply(_ context.Context, r io.Reader) error

Apply copies the content of r to os.Stdout.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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