clioutput

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package clioutput defines the JSON output envelope for cluster-facing seictl subcommands and the exit-code / category enums that are part of the public CLI contract. The envelope mirrors Kubernetes `metav1.TypeMeta` (apiVersion + kind).

Index

Constants

View Source
const (
	KindContextResult   = "ContextResult"
	KindBenchUpResult   = "BenchUpResult"
	KindBenchDownResult = "BenchDownResult"
	KindBenchListResult = "BenchListResult"
	KindChainUpResult   = "ChainUpResult"
	KindChainDownResult = "ChainDownResult"
	KindRPCUpResult     = "RPCUpResult"
	KindRPCDownResult   = "RPCDownResult"
	KindOnboardResult   = "OnboardResult"
)

Kinds emitted by cluster-facing verbs. New verbs add a constant here rather than open-coding the string at the call site.

View Source
const (
	ExitSuccess  = 0
	ExitUsage    = 2
	ExitNotFound = 3
	ExitCluster  = 4
	ExitRBAC     = 5
	ExitBench    = 10
	ExitOnboard  = 20
	ExitIdentity = 40
)
View Source
const (
	CatImagePolicy     = "image-policy"
	CatImageResolution = "image-resolution"
	CatValidation      = "validation"
	CatNamespacePolicy = "namespace-policy"
	CatApplyFailed     = "apply-failed"
	CatNameCollision   = "name-collision"
	CatFinalizerStuck  = "finalizer-stuck"
	CatTemplateRender  = "template-render"
	CatJobImmutable    = "job-immutable"

	CatAliasInvalid        = "alias-invalid"
	CatPlatformRepoMissing = "platform-repo-missing"
	CatWorkingTreeDirty    = "working-tree-dirty"
	CatGHUnauthenticated   = "gh-unauthenticated"
	CatPRCreateFailed      = "pr-create-failed"
	CatAWSCreateFailed     = "aws-create-failed"
	CatBaseBranchStale     = "base-branch-stale"
	CatWrongAccount        = "wrong-account"

	CatMalformed       = "malformed"
	CatMissing         = "missing"
	CatKubeconfigParse = "kubeconfig-parse"
	CatPermsLoose      = "perms-loose"
	CatAWSUnavailable  = "aws-unavailable"
)
View Source
const APIVersion = "seictl.sei.io/v1"

APIVersion is the stable group/version string emitted on every envelope. Breaking changes ship as `seictl.sei.io/v2` alongside v1, not as mutations to v1.

Variables

This section is empty.

Functions

func Emit

func Emit(w io.Writer, kind string, data any) error

Emit writes a success envelope to w. data is marshalled into the envelope's Data field.

func EmitError

func EmitError(w io.Writer, kind string, e *Error) error

EmitError writes an error envelope to w. Returns marshal errors only; callers should not propagate those back to the user.

Types

type Envelope

type Envelope struct {
	APIVersion string          `json:"apiVersion"`
	Kind       string          `json:"kind"`
	Data       json.RawMessage `json:"data,omitempty"`
	Error      *ErrorBody      `json:"error,omitempty"`
}

type Error

type Error struct {
	Code     int
	Category string
	Message  string
	Detail   string
}

Error is the CLI-side typed failure. Carries enough to populate ErrorBody and choose the process exit code. Implements error.

func New

func New(code int, category, message string) *Error

func Newf

func Newf(code int, category, format string, args ...any) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) WithDetail

func (e *Error) WithDetail(detail string) *Error

type ErrorBody

type ErrorBody struct {
	Code     int    `json:"code"`
	Category string `json:"category"`
	Message  string `json:"message"`
	Detail   string `json:"detail,omitempty"`
}

Jump to

Keyboard shortcuts

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