cmd

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 14 Imported by: ? 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 cmd holds what every kubectl-nv command needs before it can talk to a cluster: the kubectl configuration flags, the resolved kubeconfig path, and the factory the commands get their clients from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConfigFlags

func AddConfigFlags(flags *pflag.FlagSet, configFlags *genericclioptions.ConfigFlags)

AddConfigFlags registers the kubectl configuration flags on flags, giving --kubeconfig the -k shorthand that kubectl-nv accepted before it moved to cobra.

func UsageArgs added in v0.2.0

func UsageArgs(validate cobra.PositionalArgs) cobra.PositionalArgs

UsageArgs wraps a positional argument validator so that a failure carries its own exit code.

Without it the code depends on who runs the command: cmd/kubectl-nv turns an unsilenced error into a usage one, but a command executed any other way, by a test or by a future embedder, gets a bare error and so exit 4. Exit 4 means the run could not happen, which tells a script that the cluster is unreachable when the truth is that the user typed too many words.

Types

type Factory

type Factory interface {
	KubernetesClient() (kubernetes.Interface, error)
	DynamicClient() (dynamic.Interface, error)
	RESTConfig() (*rest.Config, error)
}

Factory hands a command the clients it needs. There is one implementation against a real cluster, built from the kubectl configuration flags; tests supply their own so that no test reaches a cluster.

func NewFactory

func NewFactory(configFlags *genericclioptions.ConfigFlags) Factory

NewFactory returns the Factory that talks to the cluster the configuration flags point at. The REST configuration and the clients are built once and reused, so a command that needs two of them does not read the kubeconfig twice.

type Options

type Options struct {
	ConfigFlags *genericclioptions.ConfigFlags
	Streams     genericiooptions.IOStreams
	Factory     Factory

	// Debug reports whether debug-level logging was asked for, by --debug, -d or
	// the DEBUG environment variable.
	Debug bool

	// Logger is where commands report progress. It writes to the error stream
	// only, so stdout stays the command's own output.
	Logger *output.Logger
}

Options is the state the root command resolves once and every subcommand reads.

func (*Options) KubeconfigDisplay

func (o *Options) KubeconfigDisplay() string

KubeconfigDisplay names the kubeconfig the clients will be built from, for reporting it to the user. It asks the client configuration rather than resolving a path of its own: a second resolver can disagree with the one that actually loads the file, and then the gather names a cluster it never looked at.

func (*Options) Log

func (o *Options) Log() *output.Logger

Log returns where this command reports progress, making a plain one over the error stream when the root has not set one, so that a command built by hand in a test still has somewhere to write.

Directories

Path Synopsis
Package adm carries the admin-level operations on the NVIDIA resources of a cluster.
Package adm carries the admin-level operations on the NVIDIA resources of a cluster.
Package debug implements "kubectl nv debug <node>": a must-gather narrowed to one node, with a summary of that node on one screen.
Package debug implements "kubectl nv debug <node>": a must-gather narrowed to one node, with a summary of that node on one screen.
Package info implements "kubectl nv info <node>", everything kubectl-nv knows about one GPU node.
Package info implements "kubectl nv info <node>", everything kubectl-nv knows about one GPU node.
Package list implements "kubectl nv list", the inventory of a cluster's GPU nodes.
Package list implements "kubectl nv list", the inventory of a cluster's GPU nodes.
Package mcp serves the kubectl-nv command tree as a Model Context Protocol server over stdio, one tool per read-only leaf command.
Package mcp serves the kubectl-nv command tree as a Model Context Protocol server over stdio, one tool per read-only leaf command.
Package root builds the kubectl-nv command tree.
Package root builds the kubectl-nv command tree.
Package schema carries the schema command, which prints the JSON Schema of one kubectl-nv kind, and the generator behind "make schema" that keeps the checked-in copies of those schemas in step with the code.
Package schema carries the schema command, which prints the JSON Schema of one kubectl-nv kind, and the generator behind "make schema" that keeps the checked-in copies of those schemas in step with the code.

Jump to

Keyboard shortcuts

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