cmd

package
v0.0.0-...-53b5417 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package cmd provides the CLI command implementations for Bosun.

Index

Constants

View Source
const (
	ExitSuccess         = 0
	ExitRuntimeError    = 1
	ExitValidationError = 2

	// M3 additions
	ExitWorkerFailed  = 10 // Worker exited with non-zero code
	ExitStopFailed    = 11 // Failed to stop stack
	ExitStartFailed   = 12 // Failed to restart stack
	ExitTimeout       = 13 // Operation timed out
	ExitImageNotFound = 14 // Worker image not found
	ExitJobNotFound   = 15 // Job name not found
	ExitInterrupted   = 16 // Execution interrupted (Ctrl+C)
)

Exit codes for Bosun CLI commands.

These constants ensure consistent exit code semantics across all commands:

  • ExitSuccess: Command completed without errors
  • ExitRuntimeError: Docker unavailable, I/O failure, network error
  • ExitValidationError: Invalid labels, missing required fields, config errors

M3 Job Execution Exit Codes (10-16 range to avoid collision with existing):

  • ExitWorkerFailed: Worker exited with non-zero code
  • ExitStopFailed: Failed to stop stack
  • ExitStartFailed: Failed to restart stack
  • ExitTimeout: Operation timed out
  • ExitImageNotFound: Worker image not found
  • ExitJobNotFound: Job name not found
  • ExitInterrupted: Execution interrupted (Ctrl+C)

Variables

This section is empty.

Functions

func ExitCodeFromError

func ExitCodeFromError(err error) int

ExitCodeFromError maps domain errors to exit codes.

func NewConfigCmd

func NewConfigCmd() *cobra.Command

NewConfigCmd creates the config subcommand group

func NewJobCmd

func NewJobCmd() *cobra.Command

NewJobCmd creates the `job` command.

func NewJobRunCmd

func NewJobRunCmd() *cobra.Command

NewJobRunCmd creates the `job run` subcommand.

func NewLabelsCmd

func NewLabelsCmd() *cobra.Command

NewLabelsCmd creates the labels subcommand

func NewPlanCmd

func NewPlanCmd() *cobra.Command

NewPlanCmd creates the plan command group for job planning operations.

func NewPlanListCmd

func NewPlanListCmd() *cobra.Command

NewPlanListCmd creates the `plan list` subcommand.

func NewPlanShowCmd

func NewPlanShowCmd() *cobra.Command

NewPlanShowCmd creates the `plan show` subcommand.

func NewRootCmd

func NewRootCmd() *cobra.Command

NewRootCmd creates the root command for bosun

func NewSnapshotCmd

func NewSnapshotCmd() *cobra.Command

NewSnapshotCmd creates the snapshot subcommand

func NewValidateCmd

func NewValidateCmd() *cobra.Command

NewValidateCmd creates the validate subcommand

Types

type ConfigSource

type ConfigSource string

ConfigSource indicates where config values come from

const (
	// SourceAuto merges all sources (default)
	SourceAuto ConfigSource = "auto"
	// SourceLabels uses Docker labels only
	SourceLabels ConfigSource = "labels"
	// SourceFile uses config file only (future)
	SourceFile ConfigSource = "file"
)

type EntityValidationError

type EntityValidationError struct {
	Entity dlabels.LabeledEntity   // The entity that failed
	Errors loader.ValidationErrors // Validation errors for this entity
}

EntityValidationError wraps validation errors with entity context

type ValidateOptions

type ValidateOptions struct {
	Source         ConfigSource // --from flag
	Scope          string       // --scope flag (empty = all)
	PrintConfig    bool         // --print flag
	ConfigFile     string       // --config flag (future)
	IncludeStopped bool         // --stopped flag
	Strict         bool         // --strict flag
}

ValidateOptions holds CLI flag values

type ValidationResult

type ValidationResult struct {
	Valid        bool                       // Overall success
	MergedConfig *schema.ConfigV1           // Merged config (if valid or for --print)
	EntityErrors []EntityValidationError    // Per-entity errors (config labels)
	JobErrors    loader.JobValidationErrors // Job label validation errors
	Warnings     []string                   // Non-fatal warnings
}

ValidationResult holds the outcome of validation

Jump to

Keyboard shortcuts

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