status

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	GeneralStatusReady              ConditionType = "Ready"
	GeneralStatusReadyTransitioning string        = "Provisioning" // Transitioning status of Ready.
	GeneralStatusError              string        = "Error"        // Error status of Ready.
)
View Source
const (
	ResourceRunStatusPending  ConditionType = "Pending"
	ResourceRunStatusPlanned  ConditionType = "Planned"
	ResourceRunStatusApplied  ConditionType = "Applied"
	ResourceRunStatusCanceled ConditionType = "Canceled"

	ResourceRunSummaryStatusPlanning string = "Planning"
	ResourceRunSummaryStatusPlanned  string = "Planned"
	ResourceRunSummaryStatusPending  string = "Pending"
	ResourceRunSummaryStatusCanceled string = "Canceled"
	ResourceRunSummaryStatusRunning  string = "Running"
	ResourceRunSummaryStatusFailed   string = "Failed"
	ResourceRunSummaryStatusSucceed  string = "Succeeded"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	// Type of condition in CamelCase.
	Type ConditionType `json:"type,omitempty"`
	// Status of the condition, one of True, False, Unknown.
	Status ConditionStatus `json:"status,omitempty"`
	// This should be when the underlying condition changed.
	LastUpdateTime time.Time `json:"lastUpdateTime,omitempty"`
	// Message is a human-readable message indicating details about the status.
	Message string `json:"message,omitempty"`
	// Reason contains a programmatic identifier indicating the reason for the condition's last transition.
	Reason string `json:"reason"`
}

Condition is the condition details.

type ConditionStatus

type ConditionStatus string

ConditionStatus is the value of status.

const (
	ConditionStatusTrue    ConditionStatus = "True"
	ConditionStatusFalse   ConditionStatus = "False"
	ConditionStatusUnknown ConditionStatus = "Unknown"
)

These are valid condition statuses. "ConditionStatusTrue" means a resource is in the condition. "ConditionStatusFalse" means a resource is not in the condition. "ConditionStatusUnknown" means a resource is in the condition or not.

type ConditionType

type ConditionType string

ConditionType is the type of status.

const (
	CatalogStatusInitialized ConditionType = "Initialized"
	CatalogStatusReady       ConditionType = "Ready"
)
const (
	ConnectorStatusConnected         ConditionType = "Connected"
	ConnectorStatusCostToolsDeployed ConditionType = "CostToolDeployed"
	ConnectorStatusCostSynced        ConditionType = "CostSynced"
	ConnectorStatusReady             ConditionType = "Ready"
)
const (
	ResourceStatusUnDeployed  ConditionType = "Undeployed"
	ResourceStatusStopped     ConditionType = "Stopped"
	ResourceStatusDeployed    ConditionType = "Deployed"
	ResourceStatusDeleted     ConditionType = "Deleted"
	ResourceStatusReady       ConditionType = "Ready"
	ResourceStatusProgressing ConditionType = "Progressing"
)
const (
	TemplateStatusInitialized ConditionType = "Initialized"
	TemplateStatusReady       ConditionType = "Ready"
)
const (
	WorkflowExecutionStatusPending  ConditionType = "Pending"
	WorkflowExecutionStatusRunning  ConditionType = "Running"
	WorkflowExecutionStatusCanceled ConditionType = "Canceled"
)
const (
	WorkflowStageExecutionStatusPending  ConditionType = "Pending"
	WorkflowStageExecutionStatusRunning  ConditionType = "Running"
	WorkflowStageExecutionStatusCanceled ConditionType = "Canceled"
)
const (
	WorkflowStepExecutionStatusPending  ConditionType = "Pending"
	WorkflowStepExecutionStatusRunning  ConditionType = "Running"
	WorkflowStepExecutionStatusCanceled ConditionType = "Canceled"
)

func (ConditionType) Exist

func (ct ConditionType) Exist(obj any) bool

Exist returns true if the status is existed, object must be a pointer.

func (ConditionType) False

func (ct ConditionType) False(obj any, message string)

False set status value to False for object field .Status.Conditions, object must be a pointer.

func (ConditionType) GetMessage

func (ct ConditionType) GetMessage(obj any) string

GetMessage get message from conditionType for object field .Status.Conditions.

func (ConditionType) IsFalse

func (ct ConditionType) IsFalse(obj any) bool

IsFalse check status value for object, object must be a pointer.

func (ConditionType) IsTrue

func (ct ConditionType) IsTrue(obj any) bool

IsTrue check status value for object, object must be a pointer.

func (ConditionType) IsUnknown

func (ct ConditionType) IsUnknown(obj any) bool

IsUnknown check status value for object, object must be a pointer.

func (ConditionType) Message

func (ct ConditionType) Message(obj any, message string)

Message set message to conditionType for object field .Status.Conditions, object must be a pointer.

func (ConditionType) Remove

func (ct ConditionType) Remove(obj any)

Remove drop status from the object field .Status.Conditions, object must be a pointer.

func (ConditionType) Reset

func (ct ConditionType) Reset(obj any, message string)

Reset clean the object field .Status.Conditions, and set the status as Unknown type into the object field .Status.Conditions, object must be a pointer.

func (ConditionType) Status

func (ct ConditionType) Status(obj any, status ConditionStatus)

Status set status value to custom value for object field .Status.Conditions, object must be a pointer.

func (ConditionType) String

func (ct ConditionType) String() string

func (ConditionType) True

func (ct ConditionType) True(obj any, message string)

True set status value to True for object field .Status.Conditions, object must be a pointer.

func (ConditionType) Unknown

func (ct ConditionType) Unknown(obj any, message string)

Unknown set status value to Unknown for object field .Status.Conditions, object must be a pointer.

type Converter

type Converter interface {
	// Convert base on input status and message and gives a converted seal status.
	Convert(string, string) *Status
}

func NewConverter

func NewConverter[T ~string](normalStatus, warningStatus, inactiveStatus, errorStatus []T) Converter

NewConverter creates a converter by the given status and status message, status not in the normalStatus and errorStatus will set transitioning to true.

  • `normalStatus` specifies the normal status list, won't change the error and transition, while summary status is in the normal status list.
  • `warningStatus` specifies the warn status list, set the warn to true, while the summary status is in the warn status list.
  • `inactiveStatus` specifies the inactive status list, set the transitioning to false, while the summary status is in the inactive status list.
  • `errorStatus` specifies the error status list, set the error to true, while the summary status is in the error status list.

type Count added in v0.4.0

type Count struct {
	Error         int `json:"error"`
	Ready         int `json:"ready"`
	Transitioning int `json:"transitioning"`
	Warning       int `json:"warning"`
	Inactive      int `json:"inactive"`
}

Count is the count of status.

type Decide

type Decide func(st ConditionStatus, reason string) *Summary

Decide returns readable and sensible status by the given condition status and reason, and moves to next path step if both returning `isError` and `isTransitioning` are false.

type Decision

type Decision[T ~string] path[T]

Decision exposes ability to customize how to make a decision on one specified step.

func (Decision[T]) Make

func (d Decision[T]) Make(step T, with Decide) Decision[T]

Make makes a decision on the given specified step with dedicated decide logic.

type Status

type Status struct {
	Summary    `json:",inline"`
	Conditions []Condition `json:"conditions,omitempty"`
	// contains filtered or unexported fields
}

Status wrap the summary of conditions and condition details.

func (*Status) Changed

func (s *Status) Changed() bool

func (Status) Equal

func (s Status) Equal(newStatue Status) bool

func (*Status) SetConditions

func (s *Status) SetConditions(conds []Condition)

func (*Status) SetSummary

func (s *Status) SetSummary(summary *Summary)

type Summary

type Summary struct {
	SummaryStatus        string `json:"summaryStatus,omitempty"`
	SummaryStatusMessage string `json:"summaryStatusMessage,omitempty"`
	Error                bool   `json:"error,omitempty"`
	Transitioning        bool   `json:"transitioning,omitempty"`
	Warning              bool   `json:"warning,omitempty"`
	Inactive             bool   `json:"inactive,omitempty"`
}

Summary is the summary of conditions.

func WalkCatalog

func WalkCatalog(st *Status) *Summary

func WalkConnector

func WalkConnector(st *Status) *Summary

WalkConnector walks the given status by connector flow.

func WalkResource added in v0.4.0

func WalkResource(st *Status) *Summary

WalkResource walks the given status by resource flow.

func WalkResourceRun added in v0.6.0

func WalkResourceRun(st *Status) *Summary

func WalkTemplate

func WalkTemplate(st *Status) *Summary

func WalkWorkflowExecution added in v0.4.0

func WalkWorkflowExecution(st *Status) *Summary

func WalkWorkflowStageExecution added in v0.4.0

func WalkWorkflowStageExecution(st *Status) *Summary

func WalkWorkflowStepExecution added in v0.4.0

func WalkWorkflowStepExecution(st *Status) *Summary

type Walker

type Walker interface {
	// Walk walks all conditions of the status and gives a proper summary.
	Walk(*Status) *Summary
}

Walker holds the steps and makes a summary of the status's conditions.

func NewWalker

func NewWalker[T ~string](stepsGroup [][]T, arranges ...func(Decision[T])) Walker

NewWalker creates a stacking walker by the given steps group, and applies the customized decision to the steps group.

  • `stepsGroup` specifies the path steps in line, logically, move to next step if the current step is done. By default, Walker decides to move to the next step on whether the corresponding condition is True status.
  • `arrange` applies the customized decision, for example, moving to next step on a dedicated step if its status is False, or changing step's display content by its status.

Jump to

Keyboard shortcuts

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