types

package
v3.6.8-1+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDiagnosticError

func IsDiagnosticError(e error) bool

Easily determine if an error is in fact a Diagnostic error

func MatchesDiagError

func MatchesDiagError(err error, id string) bool

Is the error a diagnostics error that matches the given ID?

Types

type Diagnostic

type Diagnostic interface {
	Name() string
	Description() string
	CanRun() (canRun bool, reason error)
	Check() DiagnosticResult
}

Diagnostic provides the interface for building diagnostics that can execute as part of the diagnostic framework. The Name and Description methods are used to identify which diagnostic is running in the output. The CanRun() method provides a pre-execution check for whether the diagnostic is relevant and runnable as constructed. If not, a user-facing reason for skipping the diagnostic can be given. Finally, the Check() method runs the diagnostic with the resulting messages and errors returned in a result object. It should be assumed a Diagnostic can run in parallel with other Diagnostics.

type DiagnosticError

type DiagnosticError struct {
	ID         string
	LogMessage string
	Cause      error
}

DiagnosticError is an error created by the diagnostic framework and has a little more info than a regular error to make them easier to identify in the receiver.

func (DiagnosticError) Error

func (e DiagnosticError) Error() string

Error() method means it conforms to the error interface.

type DiagnosticResult

type DiagnosticResult interface {
	// Failure is true if there are any errors entered.
	Failure() bool
	// Logs/Warnings/Errors entered into the result object
	Logs() []log.Entry
	Warnings() []DiagnosticError
	Errors() []DiagnosticError
	// <Level> just takes a plain string, no formatting
	// <Level>f provides format string params
	// <Level>t interface{} should be a log.Hash for a template
	// Error and Warning add an entry to both logs and corresponding list of errors/warnings.
	Error(id string, err error, text string)
	Warn(id string, err error, text string)
	Info(id string, text string)
	Debug(id string, text string)
}

DiagnosticResult provides a result object for diagnostics, accumulating the messages and errors that the diagnostic generates as it runs.

func NewDiagnosticResult

func NewDiagnosticResult(origin string) DiagnosticResult

NewDiagnosticResult generates an internally-implemented DiagnosticResult. The origin may be output with some log messages to help identify where in code it originated.

type SystemdUnit

type SystemdUnit struct {
	// The systemd unit name, e.g. "openshift-master"
	Name string
	// Whether it is present on the system at all
	Exists bool
	// Whether it is enabled (starts on its own at boot)
	Enabled bool
	// Whether it is currently started (and not crashed)
	Active bool
	// If it's not active, the exit code from its last execution
	ExitStatus int
}

SystemdUnit represents the information we gather about a single systemd unit of interest.

Jump to

Keyboard shortcuts

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