kubecfg

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 9 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 kubecfg connects the CLI to a cluster.

It builds a cache-less controller-runtime client from the caller's own kubeconfig — one request per operation, no informers, no watches to warm up — because a CLI process lives for milliseconds and a cache would cost more than it saves.

It also fetches server-rendered tables. Asking the API server for application/json;as=Table means the columns come from the CRD's own additionalPrinterColumns, so `patchy get findings` and `kubectl get findings` print the same columns forever, with no client-side list to keep in sync.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RowMeta

RowMeta decodes the object metadata the server attached to a table row. Returns nil when the row carries none, which callers treat as "unknown" rather than an error — a table is still printable without it.

func RowName

func RowName(row metav1.TableRow) string

RowName returns a row's object name, or "" when the row carries no metadata.

Types

type Env

type Env struct {
	// Client is a cache-less client for the patchy kinds and the built-ins.
	Client client.Client
	// Config is the REST config the client was built from, kept for the
	// hand-rolled Table requests.
	Config *rest.Config
	// Namespace is the effective namespace: the --namespace flag if given,
	// otherwise whatever the kubeconfig context selects. Empty means every
	// namespace (--all-namespaces).
	Namespace string
}

Env is a resolved connection to a cluster: what to talk to, as whom, and where to look by default.

func Connect

func Connect(opts Options) (*Env, error)

Connect resolves the kubeconfig and builds the client. It performs no requests, so a bad cluster address surfaces on first use rather than here.

func (*Env) Scope

func (e *Env) Scope() string

Scope describes where a request looks: a namespace, or every namespace.

func (*Env) Table

func (e *Env) Table(ctx context.Context, plural string, names []string, selector string) (*metav1.Table, error)

Table fetches a server-rendered table for the given resource. names, when non-empty, narrows the request to those objects; selector is an optional label selector.

The rows carry the CRD's own print columns, so nothing client-side decides what a Finding looks like in a list.

type Options

type Options struct {
	// Kubeconfig is an explicit kubeconfig path; empty uses the standard
	// $KUBECONFIG / ~/.kube/config chain.
	Kubeconfig string
	// Context overrides the kubeconfig's current-context.
	Context string
	// Namespace overrides the context's namespace.
	Namespace string
	// AllNamespaces widens every read to the whole cluster.
	AllNamespaces bool
}

Options are the connection inputs, straight from the persistent flags.

Jump to

Keyboard shortcuts

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