kubectx

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package kubectx picks the kubeconfig context an environment means.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch(ctx context.Context, source, server, token string, insecure bool) ([]byte, error)

Fetch downloads a kubeconfig: from a URL (token as bearer when set), from a file, or, with no source, generated by the Rancher that server points at (token: a Rancher API key).

func IsRancher

func IsRancher(server string) bool

IsRancher is whether server is a Rancher cluster proxy, whose kubeconfig Fetch can generate.

func Merge

func Merge(raw []byte) (string, []string, error)

Merge adds raw to the user's kubeconfig (the first file of $KUBECONFIG, else ~/.kube/config): its entries replace same-named ones, the current context stays, and the old file is kept beside it as .rig-backup. It returns the file written and the contexts raw brought.

func Resolve

func Resolve(name, server string) (string, error)

Resolve is the context to use: name when the kubeconfig has it, else one whose cluster has server, since kubeconfigs downloaded from Rancher and the like name one cluster differently on each machine. Without kubectl it returns name and leaves the error to later.

Types

This section is empty.

Jump to

Keyboard shortcuts

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