...

Package kcli

import "edge-infra.dev/pkg/k8s/kcli"
Overview
Index

Overview ▾

Package kcli contains utilities for building K8s CLIs.

type KubeConfig

KubeConfig contains configuration related to loading and parsing a Kubeconfig file for instantiating K8s clients. We don't use the built-in clientcmd flag registration utilities because we don't want to expose the full sets of flags as K8s does (eg API server URL, namespace, etc).

type KubeConfig struct {
    Context string
    Path    string
    // contains filtered or unexported fields
}

func (*KubeConfig) Client

func (k *KubeConfig) Client(opts client.Options) (client.Client, error)

Client creates a K8s client from the parsed KubeConfig. This is a helper function for binaries binding kubeconfig flags using this library.

func (*KubeConfig) DynamicClient

func (k *KubeConfig) DynamicClient() (dynamic.Interface, error)

DynamicClient creates a dynamic client from the parsed KubeConfig.

func (*KubeConfig) Mapper

func (k *KubeConfig) Mapper() (meta.RESTMapper, error)

Mapper instantiates the API resource mapper from the REST config.

func (*KubeConfig) RESTConfig

func (k *KubeConfig) RESTConfig() (*rest.Config, error)

RESTConfig returns the rest.Config required to create a K8s client.

func (*KubeConfig) RawConfig

func (k *KubeConfig) RawConfig() (clientcmdapi.Config, error)

RawConfig returns the raw client configuration file (aka kubeconfig), which can be used to check contexts, cluster names, etc.

func (*KubeConfig) RegisterFlags

func (k *KubeConfig) RegisterFlags(fs *flag.FlagSet)

RegisterFlags binds common flags to an instance of the KubeConfig struct, enabling flag reuse for any binary which needs to build a K8s client and wants to allow users to override defaults via flags.

func (*KubeConfig) SetupClientConfig

func (k *KubeConfig) SetupClientConfig() error

SetupClientConfig creates client loading configuration based on the values of bound flags, falling back to bog standard defaults if nothing is provided.