output

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package output renders platform API responses for the CLI in the format selected by the persistent --output flag (json, yaml). Falls back to raw bytes when no typed payload matches the status code (e.g. 204).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(w io.Writer, format string, v any) error

Render writes v in the requested format. Unknown formats fall back to JSON with a one-line stderr warning so an operator typo doesn't kill the call.

YAML output round-trips through JSON so the json tags on oapi-codegen structs propagate as YAML keys — without this the encoder uses Go field names (`AnnotationSyncVersion` → `annotationsyncversion`) which is useless for operators piping yaml back into other tools.

func RenderResponse

func RenderResponse(cmd *cobra.Command, resp any) error

RenderResponse extracts the typed payload from an oapi-codegen response struct (looks for JSON<status> via reflection) and writes it in the selected format. Non-2xx statuses return an error with the body content, so cobra surfaces them with exit code 1.

Types

This section is empty.

Jump to

Keyboard shortcuts

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