Help us shape the future of Go! Take the 2026 Go Developer Survey

cmdutil

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPaginationParams

func ApplyPaginationParams(
	cmd *cobra.Command,
	path string,
	resource string,
	limitFlagName string,
	limitFlagValue int,
	fallbackDefault int,
	startFlagName string,
	start int,
) (string, error)

ApplyPaginationParams appends limit and start query params to a list path. It preserves any existing query parameters on the path.

func AssumeYes

func AssumeYes(cmd *cobra.Command) bool

AssumeYes returns true when prompts should be skipped.

func ClientFromCommand

func ClientFromCommand(cmd *cobra.Command) (*client.Client, error)

ClientFromCommand returns a configured authenticated client for the command.

func Confirm

func Confirm(cmd *cobra.Command, prompt string) (bool, error)

Confirm prompts the user unless --yes is enabled.

func DecodeJSON

func DecodeJSON[T any](resp *http.Response, out *T) error

DecodeJSON decodes JSON into out and enforces a successful HTTP status.

func EffectiveLimit

func EffectiveLimit(cmd *cobra.Command, resource, flagName string, flagValue, fallbackDefault int) int

EffectiveLimit resolves the final list limit with precedence: explicit flag > per-resource config > global config > fallback default.

func EnsureSuccessStatus

func EnsureSuccessStatus(resp *http.Response) error

EnsureSuccessStatus returns an error for non-2xx responses.

func JSONOutputEnabled

func JSONOutputEnabled(cmd *cobra.Command) bool

JSONOutputEnabled returns true if JSON output is enabled for this command.

func ParseResourceLimit

func ParseResourceLimit(pair string) (resource string, limit int, ok bool)

ParseResourceLimit parses a "resource=limit" pair.

func PrintJSON

func PrintJSON(v any) error

PrintJSON prints indented JSON to stdout.

func ResolveOutputMode

func ResolveOutputMode(mode string) (runtimectx.OutputMode, error)

ResolveOutputMode validates a free-form output mode value.

func UnauthClientFromCommand

func UnauthClientFromCommand(cmd *cobra.Command) (*client.Client, error)

UnauthClientFromCommand returns a configured unauthenticated client for the command.

Types

type HTTPStatusError

type HTTPStatusError struct {
	StatusCode int
	Body       string
}

HTTPStatusError represents a non-2xx HTTP response.

func (*HTTPStatusError) Error

func (e *HTTPStatusError) Error() string

Jump to

Keyboard shortcuts

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