progress

package
v0.0.0-...-d5f93d3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package progress provides a multiplexed buildkit progress display that can be used across multiple solves.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Begin

func Begin(p Progress, message string) (end func())

Begin will send a new message to the running progress. The returned function MUST be called to ensure the message is marked as completed.

func FromReader

func FromReader(p Progress, name string, rc io.ReadCloser)

FromReader will report the progress of reading from the ReadCloser.

Types

type ChannelOption

type ChannelOption interface {
	SetChannelOption(*channelOption)
}

ChannelOption can be used to customize how a specific display channel handles messages.

func AddLabel

func AddLabel(l string) ChannelOption

AddLabel will return a specific display channel where all messages will have the provided label prepended.

type DisplayMode

type DisplayMode = progressui.DisplayMode

DisplayMode is used to set the display mode for the progress.

const (
	// DefaultMode is the default value for the DisplayMode.
	// This is effectively the same as AutoMode.
	DefaultMode = progressui.DefaultMode
	// AutoMode will choose TtyMode or PlainMode depending on if the output is
	// a tty.
	AutoMode DisplayMode = progressui.AutoMode
	// QuietMode discards all output.
	QuietMode DisplayMode = progressui.QuietMode
	// TtyMode enforces the output is a tty and will otherwise cause an error if it isn't.
	TtyMode DisplayMode = progressui.TtyMode
	// PlainMode is the human-readable plain text output. This mode is not meant to be read
	// by machines.
	PlainMode DisplayMode = progressui.PlainMode
	// RawJSONMode is the raw JSON text output. It will marshal the various solve status events
	// to JSON to be read by an external program.
	RawJSONMode DisplayMode = progressui.RawJSONMode
)

type Option

type Option interface {
	SetProgressOption(p *progress)
}

Option can be used to customize the progress display.

func WithMode

func WithMode(m DisplayMode) Option

WithMode is used to set the display mode for the progress.

func WithOutput

func WithOutput(w io.Writer) Option

WithOutput is used to direct the buildkit output to an io.Writer or console.

type Progress

type Progress interface {
	// Channel returns a new buildkit client.SolveStatus channel used for
	// buildkit to send messages to the progress display.
	Channel(opts ...ChannelOption) chan *client.SolveStatus
	// Label returns a new Progress where all messages will have the provided
	// label prepended to displayed messages.  Close MUST be called on the
	// returned Progress to free resources.
	Label(string) Progress
	// Pause will sync the Progress, then prevent further messages from being
	// written to the display channels.  Resume MUST be called after Pause.
	Pause() error
	// Resume will unblock the display channels so messages will start
	// displaying after a Pause.
	Resume()
	// Close MUST be called to release resources used and ensures all in-flight
	// messages have been handled.
	Close() error
	// Sync will ensure all in-flight messages have been handled.
	Sync() error
}

Progress defines functions for a buildkit progress display.

func NewProgress

func NewProgress(opts ...Option) Progress

NewProgress creates a new Progress display to use with buildkit solves. Close MUST be called on the returned progress to clean-up resources.

Jump to

Keyboard shortcuts

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