cmdutil

package
v2.8.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const AllFlagUsage = "Return every item, ignoring pagination"

AllFlagUsage is the shared help text for the --all flag on list commands.

View Source
const ShowAllLimit = -1

ShowAllLimit is the sentinel the Arcane API uses for "return everything". The backend honours it on every list path: DB-backed lists short-circuit to paginateDBAll (bypassing the 100-item clamp), in-memory Docker lists return the full slice, and the handlers that coerce a zero limit to 20 test for exactly 0 so they leave it alone.

View Source
const StartFlagUsage = "Offset for pagination (rounded down to a multiple of --limit on database-backed resources)"

StartFlagUsage is the shared help text for the --start flag on list commands. Database-backed resources (projects, repos, gitops-syncs, environments, registries, users, events, api-keys, roles) derive a page number from start/limit, so an offset that is not a multiple of --limit is rounded down.

Variables

This section is empty.

Functions

func AppendQuery added in v2.6.0

func AppendQuery(path string, extra url.Values) string

AppendQuery merges extra query parameters into a path, preserving any that are already present.

func ApplyPaginationParams

func ApplyPaginationParams(cmd *cobra.Command, path string, p ListParams) (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. A limit of ShowAllLimit is passed straight through so that `--limit -1` reaches the server as the documented "return everything" sentinel.

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 PrintJSON

func PrintJSON(v any) error

PrintJSON prints indented JSON to stdout.

func PrintRawJSON added in v2.6.0

func PrintRawJSON(body []byte) error

PrintRawJSON pretty-prints a raw JSON document, falling back to the bytes as-is.

func ReadJSONBody added in v2.6.0

func ReadJSONBody(resp *http.Response) ([]byte, error)

ReadJSONBody enforces a successful HTTP status and returns the raw response body. Use it when a command needs both to decode a response and to echo it verbatim, so that fields the CLI does not model — such as the counts and groups objects on the container, volume, network and gitops-sync list endpoints — survive --json output instead of being dropped by a re-marshal.

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

type ListParams added in v2.6.0

type ListParams struct {
	// Resource is the canonical resource name used to look up a configured
	// per-resource limit. See clitypes.KnownPaginatedResources.
	Resource string
	// Limit is the value of the command's --limit flag.
	Limit int
	// FallbackDefault applies when neither the flag nor config supplies a limit.
	FallbackDefault int
	// Start is the value of the command's --start flag.
	Start int
	// All requests every item, ignoring pagination entirely.
	All bool
}

ListParams describes how a list command wants its results paginated.

Jump to

Keyboard shortcuts

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