Documentation
¶
Index ¶
- Constants
- func AppendQuery(path string, extra url.Values) string
- func ApplyPaginationParams(cmd *cobra.Command, path string, p ListParams) (string, error)
- func AssumeYes(cmd *cobra.Command) bool
- func ClientFromCommand(cmd *cobra.Command) (*client.Client, error)
- func Confirm(cmd *cobra.Command, prompt string) (bool, error)
- func DecodeJSON[T any](resp *http.Response, out *T) error
- func EffectiveLimit(cmd *cobra.Command, resource, flagName string, flagValue, fallbackDefault int) int
- func EnsureSuccessStatus(resp *http.Response) error
- func JSONOutputEnabled(cmd *cobra.Command) bool
- func PrintJSON(v any) error
- func PrintRawJSON(body []byte) error
- func ReadJSONBody(resp *http.Response) ([]byte, error)
- func UnauthClientFromCommand(cmd *cobra.Command) (*client.Client, error)
- type HTTPStatusError
- type ListParams
Constants ¶
const AllFlagUsage = "Return every item, ignoring pagination"
AllFlagUsage is the shared help text for the --all flag on list commands.
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.
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
AppendQuery merges extra query parameters into a path, preserving any that are already present.
func ApplyPaginationParams ¶
ApplyPaginationParams appends limit and start query params to a list path. It preserves any existing query parameters on the path.
func ClientFromCommand ¶
ClientFromCommand returns a configured authenticated client for the command.
func DecodeJSON ¶
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 ¶
EnsureSuccessStatus returns an error for non-2xx responses.
func JSONOutputEnabled ¶
JSONOutputEnabled returns true if JSON output is enabled for this command.
func PrintRawJSON ¶ added in v2.6.0
PrintRawJSON pretty-prints a raw JSON document, falling back to the bytes as-is.
func ReadJSONBody ¶ added in v2.6.0
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.
Types ¶
type HTTPStatusError ¶
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.