client

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2024 Defense Unicorns SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial Package k8s contains k8s client logic

Index

Constants

This section is empty.

Variables

View Source
var GetCurrentContext = func() (string, string, error) {

	rules := clientcmd.NewDefaultClientConfigLoadingRules()
	config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(rules, &clientcmd.ConfigOverrides{}).RawConfig()
	if err != nil {
		return "", "", err
	}
	contextName := config.CurrentContext
	context := config.Contexts[contextName]
	if context == nil {
		return "", "", fmt.Errorf("context not found")
	}
	return contextName, context.Cluster, nil
}

Declare GetCurrentContext as a variable so it can be mocked

Functions

func IsRunningInCluster

func IsRunningInCluster() (bool, error)

IsRunningInCluster checks if the application is running in cluster

Types

type Clients

type Clients struct {
	Clientset     *kubernetes.Clientset
	MetricsClient *metricsv.Clientset
	Config        *rest.Config
}

Clients holds the various Kubernetes clients

func NewClient

func NewClient() (*Clients, error)

NewClient creates new Kubernetes cluster clients

Jump to

Keyboard shortcuts

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