k8sinternal

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = k8sClient{}
View Source
var ErrNoReadableKubeConfig = errors.New("unable to open kubeconfig file")

ErrNoReadableKubeConfig represents any error that prevents the client from opening a kubeconfig file.

Functions

func DecodeResource

func DecodeResource(b []byte) (k8s.Resource, error)

func EncodeResource

func EncodeResource(resource k8s.Resource) ([]byte, error)

func IsRunningInCluster

func IsRunningInCluster(client Client) bool

IsRunningInCluster returns true if kubeaudit is running inside a cluster

Types

type Client

type Client interface {
	InClusterConfig() (*rest.Config, error)
}

Client abstracts the API to allow testing.

type ClientOptions

type ClientOptions struct {
	// Namespace filters resources by namespace. Defaults to all namespaces.
	Namespace string
	// IncludeGenerated is a boolean option to include generated resources.
	IncludeGenerated bool
}

type KubeClient

type KubeClient interface {
	// GetAllResources gets all supported resources from the cluster
	GetAllResources(options ClientOptions) ([]k8s.Resource, error)
	// GetKubernetesVersion returns the kubernetes client version
	GetKubernetesVersion() (*version.Info, error)
	// ServerPreferredResources returns the supported resources with the version preferred by the server.
	ServerPreferredResources() ([]*metav1.APIResourceList, error)
}

func NewKubeClient

func NewKubeClient(dynamic dynamic.Interface, discovery discovery.DiscoveryInterface) KubeClient

func NewKubeClientCluster

func NewKubeClientCluster(client Client) (KubeClient, error)

NewKubeClientCluster creates a new kube client for cluster mode

func NewKubeClientLocal

func NewKubeClientLocal(configPath string, context string) (KubeClient, error)

NewKubeClientLocal creates a new kube client for local mode

Jump to

Keyboard shortcuts

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