Documentation ¶
Index ¶
- Variables
- func AddTextDiff(m map[string]Diff, name, original, current, defaultVal string) map[string]Diff
- func AnyChanges(diffs map[string]Diff) bool
- type Diff
- type HealthStatus
- func (h *HealthStatus) Changes() map[string]Diff
- func (h *HealthStatus) Error() error
- func (h *HealthStatus) HasChanges() bool
- func (h *HealthStatus) HasFailingDeps() bool
- func (h *HealthStatus) IsError() bool
- func (h *HealthStatus) IsWarning() bool
- func (h *HealthStatus) Messages() []string
- func (h *HealthStatus) ShouldDisplay() bool
- func (h *HealthStatus) UpgradeWarning(level HealthStatusCode)
- type HealthStatusCode
- type Preparer
- type Renderer
- type Resource
- type Status
- func (t *Status) AddDifference(name, original, current, defaultVal string)
- func (t *Status) AddMessage(message ...string)
- func (t *Status) Diffs() map[string]Diff
- func (t *Status) Error() error
- func (t *Status) FailingDep(id string, stat TaskStatus)
- func (t *Status) HasChanges() bool
- func (t *Status) HealthCheck() (status *HealthStatus, err error)
- func (t *Status) Messages() []string
- func (t *Status) RaiseLevel(level StatusLevel)
- func (t *Status) SetError(err error)
- func (t *Status) StatusCode() StatusLevel
- type StatusLevel
- type Task
- type TaskStatus
- type TaskWrapper
- type Tasker
- type TextDiff
- type ThunkTask
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStatusCantChange is returned when an error is not set but the level is // StatusCantChange ErrStatusCantChange = errors.New("resource cannot change because of an error") // ErrStatusFatal is returned when an error is not set but the level is // StatusFatal ErrStatusFatal = errors.New("resource encountered an error") )
error messages
Functions ¶
func AddTextDiff ¶
AddTextDiff inserts a new TextDiff into a map of names to Diffs
func AnyChanges ¶
AnyChanges takes a diff map and returns true if any of the diffs in the map have changes.
Types ¶
type HealthStatus ¶
type HealthStatus struct { TaskStatus WarningLevel HealthStatusCode DisplayLevel *HealthStatusCode FailingDeps map[string]string }
HealthStatus contains a status level, display threshold, and status message
func (*HealthStatus) Changes ¶
func (h *HealthStatus) Changes() map[string]Diff
Changes returns changes from the underlying TaskStatus diffs
func (*HealthStatus) Error ¶
func (h *HealthStatus) Error() error
Error returns nil on success. If the health checks or it's dedencies are failing an appropriate error is returned.
func (*HealthStatus) HasChanges ¶
func (h *HealthStatus) HasChanges() bool
HasChanges returns true if the status indicates that there are changes
func (*HealthStatus) HasFailingDeps ¶
func (h *HealthStatus) HasFailingDeps() bool
HasFailingDeps returns true of FailingDeps is not empty
func (*HealthStatus) IsError ¶
func (h *HealthStatus) IsError() bool
IsError returns true if the warning level is StatusError
func (*HealthStatus) IsWarning ¶
func (h *HealthStatus) IsWarning() bool
IsWarning returns true if the warning level is StatusWarning
func (*HealthStatus) Messages ¶
func (h *HealthStatus) Messages() []string
Messages returns health status messages
func (*HealthStatus) ShouldDisplay ¶
func (h *HealthStatus) ShouldDisplay() bool
ShouldDisplay returns true if the warning level is at least the display level
func (*HealthStatus) UpgradeWarning ¶
func (h *HealthStatus) UpgradeWarning(level HealthStatusCode)
UpgradeWarning will increase the warning level to at least `level`, but will not decrease it if it's already higher.
type HealthStatusCode ¶
type HealthStatusCode int
HealthStatusCode is a status indicator for health level. It should be one of:
StatusHealth StatusWarning StatusError
const ( // StatusHealthy indicates a passing health check StatusHealthy HealthStatusCode = iota // StatusWarning indicates a change is needed StatusWarning // StatusError indicates that a module is non-functional StatusError )
type Preparer ¶
Preparer wraps and implements resource.Resource in order to deserialize into regular Preparers
func NewPreparer ¶
NewPreparer wraps a given resource in this preparer
func NewPreparerWithSource ¶
NewPreparerWithSource creates a new preparer with the source included
type Renderer ¶
type Renderer interface { GetID() string Value() (value string, present bool) Render(name, content string) (string, error) }
Renderer is passed to resources
type Status ¶
type Status struct { // Differences contains the things that will change as a part of this // Status. This will be used almost exclusively in the Check phase of // operations on resources. Use `NewStatus` to get a Status with this // initialized properly. Differences map[string]Diff // Output is the human-consumable fields on this struct. Output will be // returned as the Status' messages Output []string // Level indicates the change level of the status. Level is a gradation (see // the Status* contsts above.) Level StatusLevel // contains filtered or unexported fields }
Status is the default TaskStatus implementation
func (*Status) AddDifference ¶
AddDifference adds a TextDiff to the Differences map
func (*Status) AddMessage ¶
AddMessage adds a human-readable message(s) to the output
func (*Status) Error ¶
Error returns an error, if set. If the level is StatusCantChange or StatusFatal and an error is not set, Error will generate an appropriate error message.
func (*Status) FailingDep ¶
func (t *Status) FailingDep(id string, stat TaskStatus)
FailingDep tracks a new failing dependency
func (*Status) HasChanges ¶
HasChanges returns the WillChange value
func (*Status) HealthCheck ¶
func (t *Status) HealthCheck() (status *HealthStatus, err error)
HealthCheck provides a default health check implementation for statuses
func (*Status) RaiseLevel ¶
func (t *Status) RaiseLevel(level StatusLevel)
RaiseLevel raises the status level to the given level
func (*Status) StatusCode ¶
func (t *Status) StatusCode() StatusLevel
StatusCode returns the current warning level
type StatusLevel ¶
type StatusLevel uint32
StatusLevel will be used as a level in Status. It indicates if a resource needs to be changed, as well as fatal conditions.
const ( // StatusNoChange means no changes are necessary. This status signals that // execution of dependent resources can continue. StatusNoChange StatusLevel = iota // StatusWontChange indicates an acceptable delta that wont be corrected. // This status signals that execution of dependent resources can continue. StatusWontChange // StatusWillChange indicates an unacceptable delta that will be corrected. // This status signals that execution of dependent resources can continue. StatusWillChange // StatusCantChange indicates an unacceptable delta that can't be corrected. // This is just like StatusFatal except the user will see that the resource // needs to change, but can't because of the condition specified in your // messaging. This status halts execution of dependent resources. StatusCantChange // StatusFatal indicates an error. This is just like StatusCantChange except // it does not imply that there are changes to be made. This status halts // execution of dependent resources. StatusFatal )
func (StatusLevel) String ¶
func (l StatusLevel) String() string
type Task ¶
type Task interface { Check(Renderer) (TaskStatus, error) Apply() (TaskStatus, error) }
Task controls checks and application inside the system. Check will be called first; if it indicates changes will be made then Apply will also be called. Check will be called again if Apply succeeds with no error to get the final status of the resource.
func ResolveTask ¶
ResolveTask unwraps Tasker layers until it finds an underlying Task or fails
type TaskStatus ¶
type TaskStatus interface { Diffs() map[string]Diff StatusCode() StatusLevel Messages() []string HasChanges() bool Error() error }
TaskStatus represents the results of Check called during planning or application.
type TaskWrapper ¶
type TaskWrapper struct {
Task
}
TaskWrapper provides an implementation of render.Tasker for tasks
func (*TaskWrapper) GetTask ¶
func (t *TaskWrapper) GetTask() (Task, bool)
GetTask provides Tasker.GetTask ontop of a task
type TextDiff ¶
TextDiff is the default Diff implementation
type ThunkTask ¶
ThunkTask represents an abstract task over a thunk, used when we need to serialized a thunked value.
func NewThunkedTask ¶
NewThunkedTask generates a ThunkTask from a PrepareThunk
func (*ThunkTask) Apply ¶
func (t *ThunkTask) Apply() (TaskStatus, error)
Apply returns a task status with thunk information