kubernetes

package
v1.34.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KubeVersion

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

KubeVersion is an implementation of the KubernetesVersion interface

func NewKubeVersion

func NewKubeVersion(opts ...KubeVersionOptions) *KubeVersion

NewKubeVersion returns a new KubeVersion and can be configured via KubeVersionOptions functions

func (*KubeVersion) ClientVersion

func (kv *KubeVersion) ClientVersion() VersionInfo

ClientVersion returns the VersionInfo for the client

func (*KubeVersion) ServerVersion

func (kv *KubeVersion) ServerVersion() VersionInfo

ServerVersion returns the VersionInfo for the server

type KubeVersionInfo

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

KubeVersionInfo is an implementation of the VersionInfo interface

func NewKubeVersionInfo

func NewKubeVersionInfo(out string) (*KubeVersionInfo, error)

NewKubeVersionInfo will return a KubeVersionInfo from a given JSON string

func (*KubeVersionInfo) GitVersion

func (kvi *KubeVersionInfo) GitVersion() string

GitVersion returns the string representation of the GitVersion

func (*KubeVersionInfo) Major

func (kvi *KubeVersionInfo) Major() string

Major returns the string representation of the Major version

func (*KubeVersionInfo) Minor

func (kvi *KubeVersionInfo) Minor() string

Minor returns the string representatiion of the Minor version

type KubeVersionOptions

type KubeVersionOptions func(kv *KubeVersion)

KubeVersionOptions is for configuring a KubeVersion

func WithClientVersion

func WithClientVersion(clientVersion VersionInfo) KubeVersionOptions

WithClientVersion will set the ClientVersion for a KubeVersion

func WithServerVersion

func WithServerVersion(serverVersion VersionInfo) KubeVersionOptions

WithServerVersion configures the ServerVersion for a KubeVersion

type Kubectl

type Kubectl interface {
	// CommandContext returns the CommandContext that is being used by a Kubectl implementation
	CommandContext() command.CommandContext
	// Namespace returns the namespace that a Kubectl implementation is configured to use
	Namespace() string
	// ServiceAccount returns the service account that a Kubectl implementation is configured to use
	ServiceAccount() string

	// Command is used to run any command prefaced by the tool name. i.e `kubectl ...`
	Command(options ...string) (string, error)
	// CommandInNamespace is used to run any command in a namespace, prefaced by the tool name. i.e `kubectl -n namespace ...`
	CommandInNamespace(options ...string) (string, error)
	// Apply is used to run the `apply` subcommand, and can be run in the specified namespace. i.e `kubectl apply ...` or `kubectl apply -n namespace ...`.
	Apply(inNamespace bool, options ...string) (string, error)
	// Get is used to run the `get` subcommand, and can be run in the specified namespace. i.e `kubectl get ...` or `kubectl get -n namespace ...`.
	Get(inNamespace bool, options ...string) (string, error)
	// Delete is used to run the `delete` subcommand, and can be run in the specified namespace. i.e `kubectl delete ...` or `kubectl delete -n namespace ...`.
	Delete(inNamespace bool, options ...string) (string, error)
	// Logs is used to run the `logs` subcommand, and can be run in the specified namespace. i.e `kubectl logs ...` or `kubectl logs -n namespace ...`.
	Logs(inNamespace bool, options ...string) (string, error)
	// Wait is used to run the `wait` subcommand, and can be run in the specified namespace. i.e `kubectl wait ...` or `kubectl wait -n namespace ...`.
	Wait(inNamespace bool, options ...string) (string, error)
	// Version will return the KubernetesVersion that can be retrieved from running `kubectl version`
	Version() (KubernetesVersion, error)
}

Kubectl represents a command line utility that is used for interacting with a Kubernetes cluster

type KubectlUtil

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

KubectlUtil is an implementation of the Kubectl interface that uses the `kubectl` command line utility

func NewKubectlUtil

func NewKubectlUtil(opts ...KubectlUtilOptions) *KubectlUtil

NewKubectlUtil creates a new KubectlUtil that can be configured with KubectlUtilOptions functions

func (*KubectlUtil) Apply

func (ku *KubectlUtil) Apply(inNamespace bool, options ...string) (string, error)

Apply is used to run the `kubectl apply` subcommand, and can be run in the specified namespace. i.e `kubectl apply ...` or `kubectl apply -n namespace ...`.

func (*KubectlUtil) Command

func (ku *KubectlUtil) Command(options ...string) (string, error)

Command is used to run any command prefaced by `kubectl`. i.e `kubectl ...`

func (*KubectlUtil) CommandContext

func (ku *KubectlUtil) CommandContext() command.CommandContext

CommandContext returns the CommandContext that is being used by a KubectlUtil

func (*KubectlUtil) CommandInNamespace

func (ku *KubectlUtil) CommandInNamespace(options ...string) (string, error)

CommandInNamespace is used to run any command in a namespace, prefaced by `kubectl`. i.e `kubectl -n namespace ...`

func (*KubectlUtil) Delete

func (ku *KubectlUtil) Delete(inNamespace bool, options ...string) (string, error)

Delete is used to run the `kubectl delete` subcommand, and can be run in the specified namespace. i.e `kubectl delete ...` or `kubectl delete -n namespace ...`.

func (*KubectlUtil) Get

func (ku *KubectlUtil) Get(inNamespace bool, options ...string) (string, error)

Get is used to run the `kubectl get` subcommand, and can be run in the specified namespace. i.e `kubectl get ...` or `kubectl get -n namespace ...`.

func (*KubectlUtil) Logs

func (ku *KubectlUtil) Logs(inNamespace bool, options ...string) (string, error)

Logs is used to run the `kubectl logs` subcommand, and can be run in the specified namespace. i.e `kubectl logs ...` or `kubectl logs -n namespace ...`.

func (*KubectlUtil) Namespace

func (ku *KubectlUtil) Namespace() string

Namespace returns the namespace that a KubectlUtil is configured to use

func (*KubectlUtil) ServiceAccount

func (ku *KubectlUtil) ServiceAccount() string

ServiceAccount returns the service account that a KubectlUtil is configured to use

func (*KubectlUtil) Version

func (ku *KubectlUtil) Version() (KubernetesVersion, error)

Version is used to run the `kubectl version` subcommand, and returns the KubernetesVersion that is parsed from its output

func (*KubectlUtil) Wait

func (ku *KubectlUtil) Wait(inNamespace bool, options ...string) (string, error)

Wait is used to run the `kubectl wait` subcommand, and can be run in the specified namespace. i.e `kubectl wait ...` or `kubectl wait -n namespace ...`.

type KubectlUtilOptions

type KubectlUtilOptions func(ku *KubectlUtil)

KubectlUtilOptions are functions used to configure a KubectlUtil

func WithCommandContext

func WithCommandContext(cc command.CommandContext) KubectlUtilOptions

WithCommandContext configures the CommandContext used by a KubectlUtil

func WithNamespace

func WithNamespace(ns string) KubectlUtilOptions

WithNamespace configures the namespace used by a KubectlUtil when commands are run namespaced

func WithServiceAccount

func WithServiceAccount(sa string) KubectlUtilOptions

WithServiceAccount configures the service account used by a KubectlUtil

type KubernetesVersion

type KubernetesVersion interface {
	// ClientVersion returns the VersionInfo for the client
	ClientVersion() VersionInfo
	// ServerVersion returns the VersionInfo for the server
	ServerVersion() VersionInfo
}

KubernetesVersion represents the JSON response that is returned when running something like `kubectl version`

type VersionInfo

type VersionInfo interface {
	// Major returns the string representation of the Major version
	Major() string
	// Minor returns the string representatiion of the Minor version
	Minor() string
	// GitVersion returns the string representation of the GitVersion
	GitVersion() string
}

VersionInfo represents the version information that is returned when running something like `kubectl version`

Jump to

Keyboard shortcuts

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