iohandler

package
v0.0.0-...-f6ab670 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 10 Imported by: 63

Documentation

Overview

Package iohandler implements the iohandler for the plugins

Index

Constants

View Source
const (
	// maximumPluginOutputSize represents the maximum output size that agent supports
	MaximumPluginOutputSize = 2500
)

Variables

This section is empty.

Functions

func TruncateOutput

func TruncateOutput(stdout string, stderr string, capacity int) (response string)

TruncateOutput truncates the output

Types

type DefaultIOHandler

type DefaultIOHandler struct {
	ExitCode int
	Status   contracts.ResultStatus

	// List of Writers attached to the IOHandler instance
	StdoutWriter multiwriter.DocumentIOMultiWriter
	StderrWriter multiwriter.DocumentIOMultiWriter
	// contains filtered or unexported fields
}

DefaultIOHandler is used for writing output by the plugins

func NewDefaultIOHandler

func NewDefaultIOHandler(context context.T, ioConfig contracts.IOConfiguration) *DefaultIOHandler

NewDefaultIOHandler returns a new instance of the IOHandler

func (*DefaultIOHandler) AppendError

func (out *DefaultIOHandler) AppendError(message string)

AppendError adds errors to DefaultIOHandler StandardErr.

func (*DefaultIOHandler) AppendErrorf

func (out *DefaultIOHandler) AppendErrorf(format string, params ...interface{})

AppendErrorf adds errors to DefaultIOHandler StandardErr with formatting parameters.

func (*DefaultIOHandler) AppendInfo

func (out *DefaultIOHandler) AppendInfo(message string)

AppendInfo adds info to IOHandler StandardOut.

func (*DefaultIOHandler) AppendInfof

func (out *DefaultIOHandler) AppendInfof(format string, params ...interface{})

AppendInfof adds info to DefaultIOHandler StandardOut with formatting parameters.

func (*DefaultIOHandler) Close

func (out *DefaultIOHandler) Close()

Close closes all the attached writers.

func (DefaultIOHandler) GetExitCode

func (out DefaultIOHandler) GetExitCode() int

GetExitCode returns the exit code

func (DefaultIOHandler) GetIOConfig

func (out DefaultIOHandler) GetIOConfig() contracts.IOConfiguration

GetIOConfig returns the io configuration

func (DefaultIOHandler) GetOutput

func (out DefaultIOHandler) GetOutput() interface{}

GetOutput returns the output to be appended to the response

func (DefaultIOHandler) GetStatus

func (out DefaultIOHandler) GetStatus() contracts.ResultStatus

GetStatus returns the status

func (DefaultIOHandler) GetStderr

func (out DefaultIOHandler) GetStderr() string

GetStderr returns the stderr

func (DefaultIOHandler) GetStderrWriter

func (out DefaultIOHandler) GetStderrWriter() multiwriter.DocumentIOMultiWriter

GetStderrWriter returns the stderr writer

func (DefaultIOHandler) GetStdout

func (out DefaultIOHandler) GetStdout() string

GetStdout returns the stdout

func (DefaultIOHandler) GetStdoutWriter

func (out DefaultIOHandler) GetStdoutWriter() multiwriter.DocumentIOMultiWriter

GetStdoutWriter returns the stdout writer

func (*DefaultIOHandler) Init

func (out *DefaultIOHandler) Init(filePath ...string)

Init initializes the plugin output object by creating the necessary writers

func (*DefaultIOHandler) MarkAsCancelled

func (out *DefaultIOHandler) MarkAsCancelled()

MarkAsCancelled marks a plugin as Cancelled.

func (*DefaultIOHandler) MarkAsFailed

func (out *DefaultIOHandler) MarkAsFailed(err error)

MarkAsFailed Failed marks plugin as Failed

func (*DefaultIOHandler) MarkAsInProgress

func (out *DefaultIOHandler) MarkAsInProgress()

MarkAsInProgress marks plugin as In Progress.

func (*DefaultIOHandler) MarkAsShutdown

func (out *DefaultIOHandler) MarkAsShutdown()

MarkAsShutdown marks a plugin as Failed in the case of interruption due to shutdown signal.

func (*DefaultIOHandler) MarkAsSucceeded

func (out *DefaultIOHandler) MarkAsSucceeded()

MarkAsSucceeded marks plugin as Successful.

func (*DefaultIOHandler) MarkAsSuccessWithReboot

func (out *DefaultIOHandler) MarkAsSuccessWithReboot()

MarkAsSuccessWithReboot marks plugin as Successful and requests a reboot.

func (*DefaultIOHandler) Merge

func (out *DefaultIOHandler) Merge(mergeOutput *DefaultIOHandler)

Merge plugin output objects

func (*DefaultIOHandler) RegisterOutputSource

func (out *DefaultIOHandler) RegisterOutputSource(multiWriter multiwriter.DocumentIOMultiWriter, IOModules ...iomodule.IOModule)

RegisterOutputSource returns a new output source by creating a multiwriter for the output modules.

func (*DefaultIOHandler) SetExitCode

func (out *DefaultIOHandler) SetExitCode(exitCode int)

SetExitCode sets the exit code

func (*DefaultIOHandler) SetOutput

func (out *DefaultIOHandler) SetOutput(output interface{})

SetOutput sets the output

func (*DefaultIOHandler) SetStatus

func (out *DefaultIOHandler) SetStatus(status contracts.ResultStatus)

SetStatus sets the status

func (*DefaultIOHandler) SetStderr

func (out *DefaultIOHandler) SetStderr(stderr string)

SetStderr sets the stderr

func (*DefaultIOHandler) SetStdout

func (out *DefaultIOHandler) SetStdout(stdout string)

SetStdout sets the stdout

func (DefaultIOHandler) String

func (out DefaultIOHandler) String() (response string)

String returns the output by concatenating stdout and stderr

type IOHandler

type IOHandler interface {
	Init(...string)
	RegisterOutputSource(multiwriter.DocumentIOMultiWriter, ...iomodule.IOModule)
	Close()
	String() string
	MarkAsFailed(err error)
	MarkAsSucceeded()
	MarkAsInProgress()
	MarkAsSuccessWithReboot()
	MarkAsCancelled()
	MarkAsShutdown()

	AppendInfo(message string)
	AppendInfof(format string, params ...interface{})
	AppendError(message string)
	AppendErrorf(format string, params ...interface{})

	// getters/setters
	GetStatus() contracts.ResultStatus
	GetStdout() string
	GetStderr() string
	GetExitCode() int
	GetStdoutWriter() multiwriter.DocumentIOMultiWriter
	GetStderrWriter() multiwriter.DocumentIOMultiWriter
	GetIOConfig() contracts.IOConfiguration

	SetStatus(contracts.ResultStatus)
	SetExitCode(int)
	SetOutput(interface{})
	SetStdout(string)
	SetStderr(string)
}

IOHandler Interface defines interface for IOHandler type

type PluginConfig

type PluginConfig struct {
	StdoutFileName        string
	StderrFileName        string
	StdoutConsoleFileName string
	StderrConsoleFileName string
	MaxStdoutLength       int
	MaxStderrLength       int
	OutputTruncatedSuffix string
}

PluginConfig is used for initializing plugins with default values

func DefaultOutputConfig

func DefaultOutputConfig() PluginConfig

DefaultOutputConfig returns the default values for the plugin

Directories

Path Synopsis
Package iomodule implements the output modules
Package iomodule implements the output modules
mock
Package iomodulemock implements the mock iomodule
Package iomodulemock implements the mock iomodule
Package iohandlermocks implements the mock iohandler
Package iohandlermocks implements the mock iohandler
Package multiwriter implements a multi-writer
Package multiwriter implements a multi-writer
mock
Package multiwritermock creates the mock mulitwriter
Package multiwritermock creates the mock mulitwriter

Jump to

Keyboard shortcuts

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