conditions

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MPL-2.0 Imports: 11 Imported by: 5 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package conditions provides a set of conditions which can be used to wait for some condition to be met.

Index

Constants

View Source
const OK = "OK"

OK is returned by the String method of the passed Condition.

Variables

View Source
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

func StatusLine(c Condition) string

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

type AssertionFunc func(ctx context.Context) error

AssertionFunc is called every poll interval until it returns nil.

type Condition

type Condition interface {
	fmt.Stringer
	Wait(ctx context.Context) error
}

Condition is a object which Wait()s for some condition to become true.

Condition can describe itself via String() method.

func None

func None() Condition

None is a service condition that has no conditions.

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

func WaitForAll(conditions ...Condition) Condition

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

func WaitForFileToExist(filename string) Condition

WaitForFileToExist is a service condition that will wait for the existence of a file.

func WaitForFilesToExist

func WaitForFilesToExist(filenames ...string) Condition

WaitForFilesToExist is a service condition that will wait for the existence of all the files.

func WaitForKubeconfigReady

func WaitForKubeconfigReady(filename string) Condition

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().

Jump to

Keyboard shortcuts

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