configutils

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 11 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfig

func GetConfig(opts ...GetConfigOption) (*rest.Config, error)

GetConfig creates a *rest.Config for talking to a Kubernetes API server. Kubeconfig / the '--kubeconfig' flag instruct to use the kubeconfig file at that location. Otherwise, will assume running in cluster and use the cluster provided kubeconfig.

It also applies saner defaults for QPS and burst based on the Kubernetes controller manager defaults (20 QPS, 30 burst)

Config precedence

* Kubeconfig / --kubeconfig value / flag pointing at a file

* KUBECONFIG environment variable pointing at a file

* In-cluster config if running in cluster

* $HOME/.kube/config if exists.

func GetConfigOrDie

func GetConfigOrDie(opts ...GetConfigOption) *rest.Config

GetConfigOrDie creates a *rest.Config for talking to a Kubernetes apiserver. If Kubeconfig / --kubeconfig is set, will use the kubeconfig file at that location. Otherwise, will assume running in cluster and use the cluster provided kubeconfig.

Will log an error and exit if there is an error creating the rest.Config.

Types

type Context

type Context string

Context allows specifying the context to load.

func (Context) ApplyToGetConfig

func (c Context) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type EgressSelectionName

type EgressSelectionName string

EgressSelectionName is the name of the egress configuration to use.

const (
	// EgressSelectionNameControlPlane instructs to use the controlplane egress selection.
	EgressSelectionNameControlPlane EgressSelectionName = "controlplane"
	// EgressSelectionNameEtcd instructs to use the etcd egress selection.
	EgressSelectionNameEtcd EgressSelectionName = "etcd"
	// EgressSelectionNameCluster instructs to use the cluster egress selection.
	EgressSelectionNameCluster EgressSelectionName = "cluster"
)

func (EgressSelectionName) NetworkContext

NetworkContext returns the corresponding network context of the egress selection.

type EgressSelectorConfig

type EgressSelectorConfig string

EgressSelectorConfig allows specifying the path to an egress selector config to use.

func (EgressSelectorConfig) ApplyToGetConfig

func (c EgressSelectorConfig) ApplyToGetConfig(o *GetConfigOptions)

type GetConfigOption

type GetConfigOption interface {
	// ApplyToGetConfig modifies the underlying GetConfigOptions.
	ApplyToGetConfig(o *GetConfigOptions)
}

GetConfigOption are options to a GetConfig call.

type GetConfigOptions

type GetConfigOptions struct {
	// Context is the kubeconfig context to load.
	Context string
	// Kubeconfig is the path to a kubeconfig to load.
	// If unset, the '--kubeconfig' flag is used.
	Kubeconfig *string
	// EgressSelectorConfig is the path to an egress selector config to load.
	EgressSelectorConfig string
	// EgressSelectionName is the name of the egress configuration to use.
	// Defaults to EgressSelectionNameControlPlane.
	EgressSelectionName EgressSelectionName
}

GetConfigOptions are options to supply for a GetConfig call.

func (*GetConfigOptions) ApplyOptions

func (o *GetConfigOptions) ApplyOptions(opts []GetConfigOption)

ApplyOptions applies all GetConfigOption tro this GetConfigOptions.

func (*GetConfigOptions) ApplyToGetConfig

func (o *GetConfigOptions) ApplyToGetConfig(o2 *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type Kubeconfig

type Kubeconfig string

Kubeconfig allows specifying the path to a kubeconfig file to use.

func (Kubeconfig) ApplyToGetConfig

func (k Kubeconfig) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type WithEgressSelectionName

type WithEgressSelectionName EgressSelectionName

func (WithEgressSelectionName) ApplyToGetConfig

func (w WithEgressSelectionName) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

Jump to

Keyboard shortcuts

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