exitcode

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: GPL-3.0, LGPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package exitcode defines the process exit codes clusterctl guarantees.

The codes are part of the command line contract: scripts branch on them, so they may be added to but never renumbered.

Index

Constants

View Source
const (
	// OK means every target succeeded.
	OK = 0
	// TargetFailed means clusterctl ran correctly but at least one target
	// reported a failure.
	TargetFailed = 1
	// Usage means the command line or the configuration was rejected before
	// anything was contacted.
	Usage = 2
	// Transport means a host could not be reached, authenticated with, or
	// stayed reachable for the duration of the command.
	Transport = 3
	// Interrupted means the command was cancelled, by a signal or by a
	// declined confirmation prompt.
	Interrupted = 130
)

Variables

This section is empty.

Functions

func Class added in v0.4.0

func Class(err error) progress.Class

Class is the class of progress an error that fits none of the first rules of progress.Classify gets, the class of the exit code it asks for, as CodeClass tells. It is the fallback every Bus of clusterctl's is made with, progress.Options.Classify, so that a span ends as the command would exit.

func CodeClass added in v0.4.0

func CodeClass(code int) progress.Class

CodeClass is the class of work that failed with the exit code code: Transport is progress.ClassTransport, Usage progress.ClassUsage, Interrupted progress.ClassCanceled, and any other but OK, which is no failure, progress.ClassTarget.

func Default added in v0.4.0

func Default(code int, err error) error

Default gives an error the exit code code, unless it asks for one already.

func From

func From(err error) int

From reports the exit code an error should produce. Errors that carry no code of their own count as a target failure.

func Has added in v0.4.0

func Has(err error) bool

Has reports whether an error says which exit code it asks for.

func Worst added in v0.4.0

func Worst(errs ...error) int

Worst reports the code a command exits with when it met every one of errs, as on several hosts. The first that applies wins: Interrupted, which a cancellation counts as however it was wrapped, then Transport, Usage and TargetFailed. It is OK when every error is nil.

func Wrap

func Wrap(code int, err error) error

Wrap attaches an exit code to an existing error, returning nil for nil.

Types

type Error

type Error struct {
	Code int
	Err  error
}

Error carries an exit code alongside an error. Commands return it to select an exit code other than TargetFailed.

func Errorf

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

Errorf builds an Error with a formatted message.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Jump to

Keyboard shortcuts

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