types

package
Version: v3.11.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: Apache-2.0 Imports: 7 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
	Requirements() (client bool, host bool)
	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. Requirements() identifies the common parameters this diagnostic may require. 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 DiagnosticList

type DiagnosticList []Diagnostic

DiagnosticsList is a simple list type for providing the Names() method

func (DiagnosticList) Names

func (d DiagnosticList) Names() sets.String

Names returns a set of the names of the diagnostics in the list

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 IncompleteDiagnostic

type IncompleteDiagnostic interface {
	// Complete runs just before CanRun; it can log issues to the logger. Returns error on misconfiguration.
	Complete(*log.Logger) error
}

Diagnostic provides an interface for finishing initialization of a diagnostic.

type Parameter

type Parameter struct {
	Name        string
	Description string
	Target      interface{}
	Default     interface{}
}

Parameter is used by an individual diagnostic to specify non-shared parameters for itself Name is a lowercase string that will be used to generate a CLI flag Description is used to describe the same flag Target is a pointer to what the flag should fill in Default is the default value for the flag description

type ParameterizedDiagnostic

type ParameterizedDiagnostic interface {
	Diagnostic
	AvailableParameters() []Parameter
}

ParameterizedDiagnostic is a Diagnostic that can accept arbitrary parameters specifically for it. AvailableParameters is used to describe or validate the parameters given on the command line.

type ParameterizedDiagnosticMap

type ParameterizedDiagnosticMap map[string]ParameterizedDiagnostic

ParameterizedDiagnosticMap holds PDs by name for later lookup

func NewParameterizedDiagnosticMap

func NewParameterizedDiagnosticMap(diags ...Diagnostic) ParameterizedDiagnosticMap

NewParameterizedDiagnosticMap filters PDs from a list of diagnostics into a PDMap.

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