ioutil

package
v1.4.45 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Grep                 = "grep"
	GrepRegexFlag        = "-P"
	GrepOnlyMatchingFlag = "-o"
	GrepAntiMatchFlag    = "-v"
	GrepQuietFlag        = "-q"
	GrepBeforeFlag       = "-B"
)

Grep is the grep command string

Variables

View Source
var AlwaysMatchDefinition = NewErrorDefinition(anyMatchPattern)

AlwaysMatchDefinition will match any error

Functions

func AllCurrentAzureChains

func AllCurrentAzureChains(exec utilexec.Interface, lockWaitTimeSeconds string) (map[string]struct{}, error)

func DoublePipeToGrep

func DoublePipeToGrep(command, grepCommand1, grepCommand2 utilexec.Cmd) (searchResults []byte, gotMatches bool, commandError error)

func PipeCommandToGrep

func PipeCommandToGrep(command, grepCommand utilexec.Cmd) (searchResults []byte, gotMatches bool, commandError error)

Types

type ErrorDefinition

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

ErrorDefinition defines an error by a regular expression and its error code.

func NewErrorDefinition

func NewErrorDefinition(pattern string) *ErrorDefinition

type FileCreator

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

FileCreator is a tool for: - building a buffer file - running a command with the file - handling errors in the file

func NewFileCreator

func NewFileCreator(ioShim *common.IOShim, maxTryCount int, lineFailurePatterns ...string) *FileCreator

func (*FileCreator) AddErrorToRetryOn

func (creator *FileCreator) AddErrorToRetryOn(definition *ErrorDefinition)

func (*FileCreator) AddLine

func (creator *FileCreator) AddLine(sectionID string, errorHandlers []*LineErrorHandler, items ...string)

func (*FileCreator) RunCommandOnceWithFile

func (creator *FileCreator) RunCommandOnceWithFile(cmd string, args ...string) (bool, error)

RunCommandOnceWithFile runs the command with the file once and increments the try count. It returns whether the file was altered and any error. For automatic retrying and proper logging, use RunCommandWithFile. This method can be used for external testing of file creator contents after each run.

func (*FileCreator) RunCommandWithFile

func (creator *FileCreator) RunCommandWithFile(cmd string, args ...string) error

func (*FileCreator) ToString

func (creator *FileCreator) ToString() string

ToString combines the lines in the FileCreator and ends with a new line.

type Line

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

Line defines the content, section, and error handlers for a line

type LineErrorHandler

type LineErrorHandler struct {
	Definition *ErrorDefinition
	Method     LineErrorHandlerMethod
	Callback   func()
}

LineErrorHandler defines an error and how to handle it

type LineErrorHandlerMethod

type LineErrorHandlerMethod string

LineErrorHandlerMethod defines behavior when an error occurs

const (
	// Continue specifies skipping this line and all previous lines
	Continue LineErrorHandlerMethod = "continue"
	// ContinueAndAbortSection specifies skipping this line, all previous lines, and all lines tied to this line's section
	ContinueAndAbortSection LineErrorHandlerMethod = "continue-and-abort"
)

type Section

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

Section is a logically connected components (not necessarily adjacent lines)

Jump to

Keyboard shortcuts

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