k8s

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClientNotConnected = errors.New("kubernetes client not connected")

ErrClientNotConnected kubernetes clients is not able to access the API.

View Source
var ErrIngressDomainNotFound = fmt.Errorf("ingress domain not found")

ErrIngressDomainNotFound returned when the OpenShift ingress domain is empty.

Functions

func DeleteSecret

func DeleteSecret(
	ctx context.Context,
	kube *Kube,
	name types.NamespacedName,
) error

DeleteSecret deletes a Kubernetes secret.

func EnsureOpenShiftProject

func EnsureOpenShiftProject(
	ctx context.Context,
	logger *slog.Logger,
	kube *Kube,
	projectName string,
) error

EnsureOpenShiftProject ensures the OpenShift project exists.

func GetOpenShiftIngressDomain

func GetOpenShiftIngressDomain(ctx context.Context, kube *Kube) (string, error)

GetOpenShiftIngressDomain returns the OpenShift Ingress domain.

func GetSecret

func GetSecret(
	ctx context.Context,
	kube *Kube,
	name types.NamespacedName,
) (*corev1.Secret, error)

GetSecret retrieves a Kubernetes secret by full name.

func SecretExists

func SecretExists(
	ctx context.Context,
	kube *Kube,
	name types.NamespacedName,
) (bool, error)

SecretExists checks if a Kubernetes secret exists.

Types

type FakeKube

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

func NewFakeKube

func NewFakeKube(objects ...runtime.Object) *FakeKube

func (*FakeKube) ClientSet

func (f *FakeKube) ClientSet(string) (kubernetes.Interface, error)

func (*FakeKube) Connected

func (f *FakeKube) Connected() error

func (*FakeKube) CoreV1ClientSet

func (f *FakeKube) CoreV1ClientSet(
	namespace string,
) (corev1client.CoreV1Interface, error)

func (*FakeKube) DiscoveryClient

func (f *FakeKube) DiscoveryClient(
	namespace string,
) (discovery.DiscoveryInterface, error)

func (*FakeKube) DynamicClient

func (f *FakeKube) DynamicClient(namespace string) (dynamic.Interface, error)

func (*FakeKube) GetDynamicClientForObjectRef

func (f *FakeKube) GetDynamicClientForObjectRef(
	objectRef *corev1.ObjectReference,
) (dynamic.ResourceInterface, error)

func (*FakeKube) RESTClientGetter

func (f *FakeKube) RESTClientGetter(_ string) genericclioptions.RESTClientGetter

type Interface

type Interface interface {
	ClientSet(string) (kubernetes.Interface, error)
	Connected() error
	CoreV1ClientSet(string) (corev1client.CoreV1Interface, error)
	DiscoveryClient(string) (discovery.DiscoveryInterface, error)
	DynamicClient(string) (dynamic.Interface, error)
	GetDynamicClientForObjectRef(*corev1.ObjectReference) (dynamic.ResourceInterface, error)
	RESTClientGetter(string) genericclioptions.RESTClientGetter
}

type Kube

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

Kube represents the Kubernetes client helper.

func NewKube

func NewKube(flags *flags.Flags) *Kube

NewKube instantiates the Kubernetes client helper.

func (*Kube) ClientSet

func (k *Kube) ClientSet(namespace string) (kubernetes.Interface, error)

ClientSet returns a "corev1" Kubernetes Clientset.

func (*Kube) Connected

func (k *Kube) Connected() error

Connected reads the cluster's version, to assert if the client is working. For this purpose it assumes namespace "default".

func (*Kube) CoreV1ClientSet

func (k *Kube) CoreV1ClientSet(
	namespace string,
) (corev1client.CoreV1Interface, error)

CoreV1ClientSet returns a "corev1" Kubernetes Clientset.

func (*Kube) DiscoveryClient

func (k *Kube) DiscoveryClient(namespace string) (discovery.DiscoveryInterface, error)

DiscoveryClient instantiates a discovery client for the given namespace.

func (*Kube) DynamicClient

func (k *Kube) DynamicClient(namespace string) (dynamic.Interface, error)

DynamicClient instantiates a dynamic client for the given namespace.

func (*Kube) GetDynamicClientForObjectRef

func (k *Kube) GetDynamicClientForObjectRef(
	objectRef *corev1.ObjectReference,
) (dynamic.ResourceInterface, error)

GetDynamicClientForObjectRef returns a dynamic client for the object reference.

func (*Kube) RESTClientGetter

func (k *Kube) RESTClientGetter(namespace string) genericclioptions.RESTClientGetter

RESTClientGetter returns a REST client getter for the given namespace.

Jump to

Keyboard shortcuts

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