step

package
v0.0.0-...-9ba49b0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const SubstepsFileName = "substeps.json"

Variables

View Source
var DevNullStream = devNullStream{}

DevNullStream provides an implementation of OutStreams that drops all writes to it.

View Source
var Quit = userQuitErr{}

Quit indicates that the user has canceled and does not want to proceed.

View Source
var Skip = skipErr{}

Skip can be returned from a Run or AlwaysRun callback to immediately mark the substep complete on disk and report "skipped" to the UI.

View Source
var StdStreams = &stdStreams{}

StdStreams implements OutStreams that writes directly to stdout and stderr

Functions

func HasCompleted

func HasCompleted(step idl.Step, substep idl.Substep) (bool, error)

func HasRun

func HasRun(step idl.Step, substep idl.Substep) (bool, error)

func HasStarted

func HasStarted(step idl.Step) (bool, error)

Types

type BufferedStreams

type BufferedStreams struct {
	StdoutBuf bytes.Buffer
	StderrBuf bytes.Buffer
}

BufferedStreams provides an implementation of OutStreams that stores all writes to underlying bytes.Buffer objects.

func (*BufferedStreams) Stderr

func (s *BufferedStreams) Stderr() io.Writer

func (*BufferedStreams) Stdout

func (s *BufferedStreams) Stdout() io.Writer

type LogStdStreams

type LogStdStreams struct {
	// contains filtered or unexported fields
}

LogStdStreams is a type of OutStreams that writes to both a stdout/stderr and a log file. Writing to stdout/stderr will also write to the log file. When verbose is false the streams are "not" written to stdout/stderr to match the behavior of the Hub streams.

func NewLogStdStreams

func NewLogStdStreams(verbose bool) *LogStdStreams

func (*LogStdStreams) Stderr

func (s *LogStdStreams) Stderr() io.Writer

func (*LogStdStreams) Stdout

func (s *LogStdStreams) Stdout() io.Writer

type OutStreams

type OutStreams interface {
	Stdout() io.Writer
	Stderr() io.Writer
}

type PrettyStatus

type PrettyStatus struct {
	idl.Status
}

PrettyStatus exists only to write a string description of idl.Status to the JSON representation, instead of an integer.

func (PrettyStatus) MarshalText

func (p PrettyStatus) MarshalText() ([]byte, error)

func (*PrettyStatus) UnmarshalText

func (p *PrettyStatus) UnmarshalText(buf []byte) error

type Step

type Step struct {
	// contains filtered or unexported fields
}

func Begin

func Begin(step idl.Step, sender idl.MessageSender) (*Step, error)

func New

func New(name idl.Step, sender idl.MessageSender, substepStore SubstepStore, streams OutStreams) *Step

func (*Step) AlwaysRun

func (s *Step) AlwaysRun(substep idl.Substep, f func(OutStreams) error)

func (*Step) Err

func (s *Step) Err() error

func (*Step) Run

func (s *Step) Run(substep idl.Substep, f func(OutStreams) error)

func (*Step) RunConditionally

func (s *Step) RunConditionally(substep idl.Substep, shouldRun bool, f func(OutStreams) error)

func (*Step) Streams

func (s *Step) Streams() OutStreams

type SubstepFileStore

type SubstepFileStore struct {
	// contains filtered or unexported fields
}

SubstepFileStore implements SubstepStore by providing persistent storage on disk.

func NewSubstepFileStore

func NewSubstepFileStore() (*SubstepFileStore, error)

func NewSubstepStoreUsingFile

func NewSubstepStoreUsingFile(path string) *SubstepFileStore

func (*SubstepFileStore) Read

func (f *SubstepFileStore) Read(step idl.Step, substep idl.Substep) (idl.Status, error)

func (*SubstepFileStore) ReadStep

func (f *SubstepFileStore) ReadStep(step idl.Step) (map[string]PrettyStatus, error)

func (*SubstepFileStore) Write

func (f *SubstepFileStore) Write(step idl.Step, substep idl.Substep, status idl.Status) (err error)

Write atomically updates the status file. Load the latest values from the filesystem, rather than storing in-memory on a struct to avoid having two sources of truth.

type SubstepStore

type SubstepStore interface {
	Read(idl.Step, idl.Substep) (idl.Status, error)
	Write(idl.Step, idl.Substep, idl.Status) error
}

Jump to

Keyboard shortcuts

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