kubeconfig

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package kubeconfig reads the developer's existing kubeconfig.

There is no import step and no separate credential store: if kubectl works, kubeside works. The file is read-only input. kubeside never writes to it, never copies credentials out of it, and loads every context rather than only current-context, because multi-environment is the point of the product.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RESTConfigFor

func RESTConfigFor(opts Options, contextName string) (*rest.Config, error)

RESTConfigFor builds a client config for one context.

This is where exec credential plugins (aws eks get-token, gke-gcloud-auth-plugin, kubelogin, tsh) become live: clientcmd runs them as native child processes with the real environment, which is why kubeside is not affected by the sandboxing failures that plague packaged competitors.

Types

type Config

type Config struct {
	Contexts []Context
	Current  string
	Sources  []string // files merged, in precedence order
}

Config is the merged view of every kubeconfig file in the chain.

func Load

func Load(opts Options) (*Config, error)

Load reads and merges the kubeconfig chain.

Exec credential plugins are deliberately not invoked here. Loading must stay cheap and side-effect free; plugins run later, per context, when a connection is actually made.

func (*Config) CurrentContext

func (c *Config) CurrentContext() (Context, bool)

CurrentContext returns the context kubectl would use. It connects first, so the developer's usual workspace renders while other clusters handshake.

func (*Config) Get

func (c *Config) Get(name string) (Context, bool)

Get returns the named context.

func (*Config) MustGet

func (c *Config) MustGet(name string) Context

MustGet returns the named context, or a zero Context named after it when the name is unknown. Callers that already validated the name use this to avoid a second existence check.

type Context

type Context struct {
	Name      string // context name, personal and rename-prone
	Cluster   string // cluster nickname within the kubeconfig
	Server    string // API server URL; stable across renames, so shared config keys off it
	User      string
	Namespace string // per-context default, seeds the namespace filter
	IsCurrent bool
	Insecure  bool // insecure-skip-tls-verify, surfaced as a warning in the UI

	// Exec describes the credential plugin this context authenticates with,
	// when it uses one. Captured so that a rejected credential can name the
	// command that would fix it instead of printing a bare error.
	Exec *ExecConfig
}

Context is one kubeconfig context, flattened to what kubeside needs.

type ExecConfig

type ExecConfig struct {
	Command string
	Args    []string
	Env     map[string]string
}

ExecConfig is the kubeconfig exec block for a context.

func (*ExecConfig) Describe

func (e *ExecConfig) Describe() string

Describe renders the configured credential command, used when no specific login hint is known so the developer at least sees what ran.

func (*ExecConfig) LoginHint

func (e *ExecConfig) LoginHint() string

LoginHint returns the command a developer should run when this context's credentials are rejected, or "" when nothing useful can be said.

It never invents a command that is not implied by the kubeconfig. Guessing wrong here is worse than staying quiet: it sends someone to run something that cannot help.

type Options

type Options struct {
	// ExplicitPath is the --kubeconfig flag. Highest precedence.
	ExplicitPath string
	// Precedence overrides the KUBECONFIG chain. Tests set this directly;
	// production leaves it nil so clientcmd reads the environment.
	Precedence []string
}

Options selects which files to read. Zero value follows kubectl: the KUBECONFIG environment chain, falling back to ~/.kube/config.

Jump to

Keyboard shortcuts

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