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 ¶
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 ¶
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) 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.