client

package
v0.0.0-...-90065ab Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientset

func NewClientset(opts *Options) (*kubernetes.Clientset, error)

NewClientset creates a new Kubernetes clientset. It takes an `opts` pointer to an `Options` struct which contains the path to the kubeconfig file. It returns a `*kubernetes.Clientset` and an `error` if there was a failure. It utilizes the `NewClientsetWithRestConfig` function to create the clientset. If there was an error creating the clientset, an error is returned along with `nil` for the clientset.

func NewClientsetWithRestConfig

func NewClientsetWithRestConfig(opts *Options) (*kubernetes.Clientset, *rest.Config, error)

NewClientsetWithRestConfig creates a new Kubernetes clientset and REST config. It takes an `opts` pointer to an `Options` struct which contains the path to the kubeconfig file. It returns a `*kubernetes.Clientset`, `*rest.Config`, and an `error` if there was a failure. It utilizes the `NewRESTConfig` function to create the REST config, then uses the REST config to create the clientset. If there was an error creating the REST config or the clientset, an error is returned along with `nil` for the clientset and config.

func NewRESTConfig

func NewRESTConfig(opts *Options) (config *rest.Config, err error)

NewRESTConfig creates a new Kubernetes REST config based on the provided options. It takes an `opts` pointer to an `Options` struct which contains the path to the kubeconfig file. If the `opts` contains a non-empty kubeconfig file path, it uses `clientcmd.BuildConfigFromFlags` to build the config. If the config is not specified or there is an error building it, it falls back to using `rest.InClusterConfig`. The function returns the created REST config and an error if there was a failure.

func WithContext

func WithContext(ctx context.Context, opts *Options) context.Context

WithContext sets the value of the options in the given context. It returns a new context with the updated value.

Types

type Options

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

Options represents the configuration options for a kubernetes client.

func FromContext

func FromContext(ctx context.Context) *Options

FromContext retrieves the *Options value from the given context. If the value exists and is of type *Options, it is returned. Otherwise, a new empty *Options is returned.

func (*Options) BindFlags

func (o *Options) BindFlags(fs *flag.FlagSet)

BindFlags adds the "kubeconfig" flag to the given FlagSet. It binds the value of the flag to the configFilePath field of the Options struct. The flag is used to specify the absolute path to the kubeconfig file.

func (*Options) BindPFlags

func (o *Options) BindPFlags(fs *pflag.FlagSet)

BindPFlags adds the "kubeconfig" flag to the given FlagSet. It binds the value of the flag to the configFilePath field of the Options struct. The flag is used to specify the absolute path to the kubeconfig file.

func (*Options) GetConfigFilePath

func (o *Options) GetConfigFilePath() string

GetConfigFilePath retrieves the kubeconfig file path.

Jump to

Keyboard shortcuts

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