Documentation
¶
Index ¶
- func NewClientset(opts *Options) (*kubernetes.Clientset, error)
- func NewClientsetWithRestConfig(opts *Options) (*kubernetes.Clientset, *rest.Config, error)
- func NewRESTConfig(opts *Options) (config *rest.Config, err error)
- func WithContext(ctx context.Context, opts *Options) context.Context
- type Options
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 ¶
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 ¶
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.
Types ¶
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options represents the configuration options for a kubernetes client.
func FromContext ¶
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 ¶
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 ¶
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 ¶
GetConfigFilePath retrieves the kubeconfig file path.