cli

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package cli provides shared CLI helpers used across Deployah commands.

It defines exit codes, release view models for table and structured output, and rendering utilities that keep command handlers consistent.

Exit codes

Use ExitSuccess, ExitError, and related constants so every command reports failures the same way to shells and CI.

Index

Constants

View Source
const (
	// ExitSuccess indicates successful program execution
	ExitSuccess = 0

	// ExitError is the exit code used when the application encounters an error
	ExitError = 1

	// ExitTimedOut is the exit code used when the application times out
	ExitTimedOut = 124
)

Exit Codes

View Source
const (
	// OutputFormatTable formats output as a table
	OutputFormatTable = "table"

	// OutputFormatJSON formats output as JSON
	OutputFormatJSON = "json"

	// OutputFormatYAML formats output as YAML
	OutputFormatYAML = "yaml"
)

Output Formats

View Source
const OutputFormatTree = "tree"

OutputFormatTree formats output as a tree

Variables

DeleteOutputFormats lists valid output formats for delete dry-run preview.

OutputFormats contains all valid output formats

Functions

func Render

func Render(c *nabat.Context, format string, headers []string, rows [][]string, data any) error

Render outputs data in the given format using Nabat structured output. headers and rows are used for table format; data is used for JSON and YAML.

Types

type ReleaseViewModel

type ReleaseViewModel struct {
	Project      string         `json:"project" yaml:"project"`
	Environment  string         `json:"environment" yaml:"environment"`
	Release      string         `json:"release" yaml:"release"`
	Namespace    string         `json:"namespace" yaml:"namespace"`
	Status       string         `json:"status" yaml:"status"`
	Revision     int            `json:"revision" yaml:"revision"`
	LastDeployed string         `json:"lastDeployed" yaml:"lastDeployed"`
	Age          string         `json:"age" yaml:"age"`
	Description  string         `json:"description,omitempty" yaml:"description,omitempty"`
	Values       map[string]any `json:"values,omitempty" yaml:"values,omitempty"`
	Notes        string         `json:"notes,omitempty" yaml:"notes,omitempty"`
	PodCount     int            `json:"podCount" yaml:"podCount"`
	ReadyPods    int            `json:"readyPods" yaml:"readyPods"`
	PodStatus    string         `json:"podStatus" yaml:"podStatus"` // e.g., "3/3", "2/3", "0/3"
}

ReleaseViewModel is the JSON and YAML output shape for Helm releases. Field values match the table output for the same release.

func ReleaseToViewModel

func ReleaseToViewModel(rel *v1.Release) ReleaseViewModel

ReleaseToViewModel converts a Helm release to a view model for output.

func ReleaseToViewModelWithPods

func ReleaseToViewModelWithPods(ctx context.Context, k8sClient *k8s.Client, rel *v1.Release) ReleaseViewModel

ReleaseToViewModelWithPods converts a Helm release to a view model with pod information.

Jump to

Keyboard shortcuts

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