clistate

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2018 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package state exposes common helpers for working with state from the CLI.

This is a separate package so that backends can use this for consistent messaging without creating a circular reference to the command package.

Index

Constants

View Source
const (
	LockThreshold    = 400 * time.Millisecond
	LockMessage      = "Acquiring state lock. This may take a few moments..."
	LockErrorMessage = `` /* 295-byte string literal not displayed */

	UnlockMessage      = "Releasing state lock. This may take a few moments..."
	UnlockErrorMessage = `` /* 787-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Locker added in v0.11.4

type Locker interface {
	// Lock the provided state, storing the reason string in the LockInfo.
	Lock(s state.State, reason string) error
	// Unlock the previously locked state.
	// An optional error can be passed in, and will be combined with any error
	// from the Unlock operation.
	Unlock(error) error
}

Locker allows for more convenient usage of the lower-level state.Locker implementations. The state.Locker API requires passing in a state.LockInfo struct. Locker implementations are expected to create the required LockInfo struct when Lock is called, populate the Operation field with the "reason" string provided, and pass that on to the underlying state.Locker. Locker implementations are also expected to store any state required to call Unlock, which is at a minimum the LockID string returned by the state.Locker.

func NewLocker added in v0.11.4

func NewLocker(
	ctx context.Context,
	timeout time.Duration,
	ui cli.Ui,
	color *colorstring.Colorize) Locker

Create a new Locker. This Locker uses state.LockWithContext to retry the lock until the provided timeout is reached, or the context is canceled. Lock progress will be be reported to the user through the provided UI.

func NewNoopLocker added in v0.11.4

func NewNoopLocker() Locker

NewNoopLocker returns a valid Locker that does nothing.

Jump to

Keyboard shortcuts

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