Documentation
¶
Overview ¶
Package conditions provides a set of conditions which can be used to wait for some condition to be met.
Index ¶
- Constants
- Variables
- func StatusLine(c Condition) string
- type AssertionFunc
- type Condition
- func None() Condition
- func PollingCondition(description string, assertion AssertionFunc, interval time.Duration) Condition
- func WaitForAll(conditions ...Condition) Condition
- func WaitForFileToExist(filename string) Condition
- func WaitForFilesToExist(filenames ...string) Condition
- func WaitForKubeconfigReady(filename string) Condition
- type State
- type Stateful
Constants ¶
const OK = "OK"
OK is returned by the String method of the passed Condition.
Variables ¶
var ErrSkipAssertion = errors.New("SKIP")
ErrSkipAssertion is used as a return value from AssertionFunc to indicate that this assertion (and, by extension, condition, and check) is to be skipped. It is not returned as an error by any Condition's Wait method but recorded as description and returned by String method.
Functions ¶
func StatusLine ¶ added in v1.14.0
StatusLine returns the human-readable status line: the condition's description decorated with its current state (": ...", ": OK", ": SKIP", or ": <error>"). Conditions that don't implement Stateful are returned unchanged.
Types ¶
type AssertionFunc ¶
AssertionFunc is called every poll interval until it returns nil.
type Condition ¶
Condition is a object which Wait()s for some condition to become true.
Condition can describe itself via String() method.
func PollingCondition ¶
func PollingCondition(description string, assertion AssertionFunc, interval time.Duration) Condition
PollingCondition converts AssertionFunc into Condition by calling it every interval until it completes or the context is canceled.
func WaitForAll ¶
WaitForAll creates a condition which waits for all the conditions to be successful.
If the condition is nil, it is ignored. WaitForAll(nil) return nil.
func WaitForFileToExist ¶
WaitForFileToExist is a service condition that will wait for the existence of a file.
func WaitForFilesToExist ¶
WaitForFilesToExist is a service condition that will wait for the existence of all the files.
func WaitForKubeconfigReady ¶
WaitForKubeconfigReady is a condition that will wait for the kubeconfig to be ready.
type State ¶ added in v1.14.0
type State int
State is the observable lifecycle state of a Condition.
const ( // StateRunning means the condition is not yet done; the last poll may have errored transiently. StateRunning State = iota // StateSucceeded means the condition's assertion returned nil. StateSucceeded // StateSkipped means the condition's assertion returned ErrSkipAssertion. StateSkipped // StateFailed means Wait returned non-nil; the condition will not be retried. StateFailed )
type Stateful ¶ added in v1.14.0
type Stateful interface {
Condition
// State returns the current state and the last non-fatal poll error
// (nil unless running after a transient error).
State() (State, error)
}
Stateful is an optional Condition extension exposing typed progress state, so consumers render status without parsing String().