options

package
v0.0.0-...-54b4948 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: Apache-2.0 Imports: 33 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// ProcessImplementationBlocking suggests that the process
	// constructor use a blocking implementation. Some managers
	// may override this option. Blocking implementations
	// typically require the manager to maintain multiple
	// go routines.
	ProcessImplementationBlocking = "blocking"
	// ProcessImplementationBasic suggests that the process
	// constructor use a basic implementation. Some managers
	// may override this option. Basic implementations are more
	// simple than blocking implementations.
	ProcessImplementationBasic = "basic"
)
View Source
const (
	LoggingPayloadFormatBSON   = "bson"
	LoggingPayloadFormatJSON   = "json"
	LoggingPayloadFormatString = "string"
)

Constants representing logging payload formats for SendMessages.

View Source
const (
	// DefaultLogName is the default name for logs emitted by Jasper.
	DefaultLogName = "jasper"
)
View Source
const LogBuildloggerV2 = "buildloggerv2"

LogBuildloggerV2 is the name for the Buildlogger v2 logger.

View Source
const LogDefault = "default"

LogDefault is the name for the default logger.

View Source
const LogFile = "file"

LogFile is the name for the file logger.

View Source
const LogInMemory = "in-memory"

LogInMemory is the name for the in-memory logger.

View Source
const LogInherited = "inherited"

LogInherited is the name for the inherited logger.

View Source
const LogSplunk = "splunk"

LogSplunk is the name for the Splunk logger.

Variables

This section is empty.

Functions

func NewSafeSender

func NewSafeSender(baseSender send.Sender, opts BaseOptions) (send.Sender, error)

NewSafeSender returns a grip send.Sender with the given base options. It overwrites the underlying Close method in order to ensure that both the base sender and buffered sender are closed correctly.

func OSSupportsDocker

func OSSupportsDocker(os string) bool

OSSupportsDocker returns whether or not the operating system is supported by Docker.

Types

type Archive

type Archive struct {
	ShouldExtract bool
	Format        ArchiveFormat
	TargetPath    string
}

Archive encapsulates options related to management of archive files.

func (Archive) Validate

func (opts Archive) Validate() error

Validate checks the archive file options.

type ArchiveFormat

type ArchiveFormat string

ArchiveFormat represents an archive file type.

const (
	// ArchiveAuto is an ArchiveFormat that does not force any particular type of
	// archive format.
	ArchiveAuto ArchiveFormat = "auto"
	// ArchiveTarGz is an ArchiveFormat for gzipped tar archives.
	ArchiveTarGz ArchiveFormat = "targz"
	// ArchiveZip is an ArchiveFormat for Zip archives.
	ArchiveZip ArchiveFormat = "zip"
)

func (ArchiveFormat) Validate

func (f ArchiveFormat) Validate() error

Validate checks that the ArchiveFormat is a recognized format.

type BaseOptions

type BaseOptions struct {
	Level  send.LevelInfo `json:"level" bson:"level"`
	Buffer BufferOptions  `json:"buffer" bson:"buffer"`
	Format LogFormat      `json:"format" bson:"format"`
}

BaseOptions are the base options necessary for setting up most loggers.

func (*BaseOptions) Validate

func (opts *BaseOptions) Validate() error

Validate ensures that BaseOptions is valid.

type BufferOptions

type BufferOptions struct {
	Buffered bool          `bson:"buffered" json:"buffered" yaml:"buffered"`
	Duration time.Duration `bson:"duration" json:"duration" yaml:"duration"`
	MaxSize  int           `bson:"max_size" json:"max_size" yaml:"max_size"`
}

BufferOptions packages options for whether or not a Logger should be buffered and the duration and size of the respective buffer in the case that it should be.

func (*BufferOptions) Validate

func (opts *BufferOptions) Validate() error

Validate ensures that BufferOptions is valid.

type BuildloggerV2Options

type BuildloggerV2Options struct {
	Buildlogger send.BuildloggerConfig `json:"buildlogger" bson:"buildlogger"`
	Base        BaseOptions            `json:"base" bson:"base"`
}

BuildloggerV2Options encapsulates the options for creating a Buildlogger v2 logger.

func (*BuildloggerV2Options) Configure

func (opts *BuildloggerV2Options) Configure() (send.Sender, error)

Configure returns a send.Sender based on the Buildlogger v2 options.

func (*BuildloggerV2Options) Type

func (*BuildloggerV2Options) Type() string

Type returns the log type for the Buildlogger v2.

type Cache

type Cache struct {
	Disabled   bool          `json:"disabled"`
	PruneDelay time.Duration `json:"prune_delay"`
	MaxSize    int           `json:"max_size"`
}

Cache represent the configuration options for the LRU cache.

func (Cache) Validate

func (opts Cache) Validate() error

Validate checks for valid cache options.

type CachedLogger

type CachedLogger struct {
	ID        string    `bson:"id" json:"id" yaml:"id"`
	ManagerID string    `bson:"manager_id" json:"manager_id" yaml:"manager_id"`
	Accessed  time.Time `bson:"accessed" json:"accessed" yaml:"accessed"`

	// These are not set if the CachedLogger is returned from a remote
	// manager.
	Error  send.Sender `bson:"-" json:"-" yaml:"-"`
	Output send.Sender `bson:"-" json:"-" yaml:"-"`
}

CachedLogger is the cached item representing a process's output. It captures information about the cached item, as well as interfaces for sending log messages.

func (*CachedLogger) Close

func (cl *CachedLogger) Close() error

Close closes the underlying senders in the CachedLogger.

func (*CachedLogger) Send

func (cl *CachedLogger) Send(lp *LoggingPayload) error

Send resolves a sender from the cached logger (either the error or output endpoint), and then sends the message from the data payload. This method ultimately is responsible for converting the payload to a message format.

type Command

type Command struct {
	ID              string          `json:"id,omitempty"`
	Commands        [][]string      `json:"commands"`
	Process         Create          `json:"proc_opts,omitempty"`
	Remote          *Remote         `json:"remote_options,omitempty"`
	ContinueOnError bool            `json:"continue_on_error,omitempty"`
	IgnoreError     bool            `json:"ignore_error,omitempty"`
	Priority        level.Priority  `json:"priority,omitempty"`
	RunBackground   bool            `json:"run_background,omitempty"`
	Sudo            bool            `json:"sudo,omitempty"`
	SudoUser        string          `json:"sudo_user,omitempty"`
	Prerequisite    func() bool     `json:"-"`
	PostHook        CommandPostHook `json:"-"`
	PreHook         CommandPreHook  `json:"-"`
}

Command represents jasper.Command options that are configurable by the user.

func (*Command) Validate

func (opts *Command) Validate() error

Validate ensures that the options passed to the command are valid.

type CommandPostHook

type CommandPostHook func(error) error

CommandPostHook describes a common function type to run after the command completes and processes its error, potentially overriding the output of the command.

func MergeAbortingPassthroughPostHooks

func MergeAbortingPassthroughPostHooks(fns ...CommandPostHook) CommandPostHook

MergeAbortingPassthroughPostHooks produces a post hook that returns the error of the first post hook passed that does not return nil. If none of the passed functions return an error, the hook returns the original error.

func MergeAbortingPostHooks

func MergeAbortingPostHooks(fns ...CommandPostHook) CommandPostHook

MergeAbortingPostHooks produces a post hook that returns the first error returned by one of it's argument functions, and returns nil if no function returns an error.

func MergePostHooks

func MergePostHooks(fns ...CommandPostHook) CommandPostHook

MergePostHooks runs all post hooks, collecting the errors and merging them.

type CommandPreHook

type CommandPreHook func(*Command, *Create)

CommandPreHook describes a common function type to run before sub-commands in a command object and can modify the state of the command.

func MergePreHooks

func MergePreHooks(fns ...CommandPreHook) CommandPreHook

MergePreHooks produces a single PreHook function that runs all defined prehooks.

func NewDefaultLoggingPreHook

func NewDefaultLoggingPreHook(lp level.Priority) CommandPreHook

NewDefaultLoggingPreHook uses the global grip logger to log a debug message at the specified priority level.

func NewLoggingPreHook

func NewLoggingPreHook(logger grip.Journaler, lp level.Priority) CommandPreHook

NewLoggingPreHook provides a logging message for debugging purposes that prints information from the creation options.

func NewLoggingPreHookFromSender

func NewLoggingPreHookFromSender(sender send.Sender, lp level.Priority) CommandPreHook

NewLoggingPreHookFromSender produces a logging prehook that wraps a sender.

type Create

type Create struct {
	Args        []string          `bson:"args" json:"args" yaml:"args"`
	Environment map[string]string `bson:"env,omitempty" json:"env,omitempty" yaml:"env,omitempty"`
	// OverrideEnviron overrides the default behavior so that the process
	// environment does not inherit the currently executing process's
	// environment. By default, the process will inherit the current process's
	// environment. This is ignored if Remote or Docker options are specified.
	OverrideEnviron bool `bson:"override_env,omitempty" json:"override_env,omitempty" yaml:"override_env,omitempty"`
	// Synchronized specifies whether the process should be thread-safe or not.
	// This is not guaranteed to be respected for managed processes.
	Synchronized bool `bson:"synchronized" json:"synchronized" yaml:"synchronized"`
	// Implementation specifies the local process implementation to use. This
	// is not guaranteed to be respected for managed processes.
	Implementation   string `bson:"implementation,omitempty" json:"implementation,omitempty" yaml:"implementation,omitempty"`
	WorkingDirectory string `bson:"working_directory,omitempty" json:"working_directory,omitempty" yaml:"working_directory,omitempty"`
	Output           Output `bson:"output" json:"output" yaml:"output"`
	// Remote specifies options for creating processes over SSH.
	Remote *Remote `bson:"remote,omitempty" json:"remote,omitempty" yaml:"remote,omitempty"`
	// Docker specifies options for creating processes in Docker containers.
	Docker *Docker `bson:"docker,omitempty" json:"docker,omitempty" yaml:"docker,omitempty"`
	// TimeoutSecs takes precedence over Timeout. On remote interfaces,
	// TimeoutSecs should be set instead of Timeout.
	TimeoutSecs int           `bson:"timeout_secs,omitempty" json:"timeout_secs,omitempty" yaml:"timeout_secs,omitempty"`
	Timeout     time.Duration `bson:"timeout,omitempty" json:"-" yaml:"-"`
	Tags        []string      `bson:"tags,omitempty" json:"tags,omitempty" yaml:"tags,omitempty"`
	OnSuccess   []*Create     `bson:"on_success,omitempty" json:"on_success,omitempty" yaml:"on_success"`
	OnFailure   []*Create     `bson:"on_failure,omitempty" json:"on_failure,omitempty" yaml:"on_failure"`
	OnTimeout   []*Create     `bson:"on_timeout,omitempty" json:"on_timeout,omitempty" yaml:"on_timeout"`
	// StandardInputBytes takes precedence over StandardInput. On remote
	// interfaces, StandardInputBytes should be set instead of StandardInput.
	StandardInput      io.Reader `bson:"-" json:"-" yaml:"-"`
	StandardInputBytes []byte    `bson:"stdin_bytes" json:"stdin_bytes" yaml:"stdin_bytes"`
	// contains filtered or unexported fields
}

Create contains options related to starting a process. This includes execution configuration, post-execution triggers, and output configuration. It is not safe for concurrent access.

func MakeCreation

func MakeCreation(cmdStr string) (*Create, error)

MakeCreation takes a command string and returns an equivalent Create struct that would spawn a process corresponding to the given command string.

func (*Create) AddEnvVar

func (opts *Create) AddEnvVar(k, v string)

AddEnvVar adds an environment variable to the Create struct on which this method is called. If the Environment map is nil, this method will instantiate one.

func (*Create) Close

func (opts *Create) Close() error

Close will execute the closer functions assigned to the Create. This function is often called as a trigger at the end of a process' lifetime in Jasper.

func (*Create) Copy

func (opts *Create) Copy() *Create

Copy returns a copy of the options for only the exported fields. Unexported fields are cleared.

func (*Create) Hash

func (opts *Create) Hash() hash.Hash

Hash returns the canonical hash implementation for the create options (and thus the process it will create.)

func (*Create) RegisterCloser

func (opts *Create) RegisterCloser(fn func() error)

RegisterCloser adds the closer function to the processes closer functions, which are called when the process finishes running.

func (*Create) Resolve

func (opts *Create) Resolve(ctx context.Context) (exe executor.Executor, t time.Time, resolveErr error)

Resolve creates the command object according to the create options. It returns the resolved command and the deadline when the command will be terminated by timeout. If there is no deadline, it returns the zero time.

func (*Create) ResolveEnvironment

func (opts *Create) ResolveEnvironment() []string

ResolveEnvironment returns the (Create).Environment as a slice of environment variables in the form "key=value".

func (*Create) Validate

func (opts *Create) Validate() error

Validate ensures that Create is valid for non-remote interfaces.

type DefaultLoggerOptions

type DefaultLoggerOptions struct {
	Prefix string      `json:"prefix" bson:"prefix"`
	Base   BaseOptions `json:"base" bson:"base"`
}

DefaultLoggerOptions encapsulates the options for creating a logger that logs to the native standard streams (i.e. stdout, stderr).

func (*DefaultLoggerOptions) Configure

func (opts *DefaultLoggerOptions) Configure() (send.Sender, error)

Configure returns a send.Sender based on the default logging options.

func (*DefaultLoggerOptions) Type

func (*DefaultLoggerOptions) Type() string

Type returns the log type for default loggers.

func (*DefaultLoggerOptions) Validate

func (opts *DefaultLoggerOptions) Validate() error

Validate checks that a default prefix is specified and that the common base options are valid.

type Docker

type Docker struct {
	Host       string `bson:"host,omitempty" json:"host,omitempty" yaml:"host,omitempty"`
	Port       int    `bson:"port,omitempty" json:"port,omitempty" yaml:"port,omitempty"`
	APIVersion string `bson:"api_version,omitempty" json:"api_version,omitempty" yaml:"api_version,omitempty"`
	Image      string `bson:"image,omitempty" json:"image,omitempty" yaml:"image,omitempty"`
	// OS refers to the major operating system on which the Docker container
	// runs. If unspecified, this defaults to the runtime GOOS.
	OS string `bson:"os,omitempty" json:"os,omitempty" yaml:"os,omitempty"`
	// Arch is the CPU architecture of the machine on which the Docker container
	// runs. If unspecified, this defaults to the runtime GOARCH.
	Arch string `bson:"arch,omitempty" json:"arch,omitempty" yaml:"arch,omitempty"`
}

Docker encapsulates options related to connecting to a Docker daemon.

func (*Docker) Copy

func (opts *Docker) Copy() *Docker

Copy returns a copy of the options for only the exported fields.

func (*Docker) Resolve

func (opts *Docker) Resolve() (*client.Client, error)

Resolve converts the Docker options into options to initialize a Docker client.

func (*Docker) Validate

func (opts *Docker) Validate() error

Validate checks whether all the required fields are set and sets defaults if none are specified.

type Download

type Download struct {
	URL         string  `json:"url"`
	Path        string  `json:"path"`
	ArchiveOpts Archive `json:"archive_opts"`
}

Download represents the options to download a file to a given path and optionally extract its contents.

func (Download) Download

func (opts Download) Download() error

Download executes the download operation.

func (Download) Extract

func (opts Download) Extract() error

Extract extracts the download to the path specified, using the archive format specified.

func (Download) Validate

func (opts Download) Validate() error

Validate checks the download options.

type FileLoggerOptions

type FileLoggerOptions struct {
	Filename string      `json:"filename" bson:"filename"`
	Base     BaseOptions `json:"base" bson:"base"`
}

FileLoggerOptions encapsulates the options for creating a file logger.

func (*FileLoggerOptions) Configure

func (opts *FileLoggerOptions) Configure() (send.Sender, error)

Configure returns a send.Sender based on the file options.

func (*FileLoggerOptions) Type

func (*FileLoggerOptions) Type() string

Type returns the log type for file loggers.

func (*FileLoggerOptions) Validate

func (opts *FileLoggerOptions) Validate() error

Validate checks that the file name is given and that the common base options are valid.

type Filter

type Filter string

Filter is type for classifying and grouping types of processes in filter operations, such as that found in List() on Managers.

const (
	// Running is a filter for processes that have not yet completed and are
	// still running.
	Running Filter = "running"
	// Terminated is the opposite of the Running filter.
	Terminated Filter = "terminated"
	// All is a filter that is satisfied by any process.
	All Filter = "all"
	// Failed refers to processes that have terminated unsuccessfully.
	Failed Filter = "failed"
	// Successful refers to processes that have terminated successfully.
	Successful Filter = "successful"
)

func (Filter) Validate

func (f Filter) Validate() error

Validate ensures that Filter is valid.

type InMemoryLoggerOptions

type InMemoryLoggerOptions struct {
	InMemoryCap int         `json:"in_memory_cap" bson:"in_memory_cap"`
	Base        BaseOptions `json:"base" bson:"base"`
}

InMemoryLoggerOptions encapsulates the options for creating an in-memory logger.

func (*InMemoryLoggerOptions) Configure

func (opts *InMemoryLoggerOptions) Configure() (send.Sender, error)

Configure returns a send.Sender based on the in-memory logger options.

func (*InMemoryLoggerOptions) Type

func (*InMemoryLoggerOptions) Type() string

Type returns the log type for in-memory loggers.

func (*InMemoryLoggerOptions) Validate

func (opts *InMemoryLoggerOptions) Validate() error

Validate checks that the in-memory capacity is specified and that the common base options are valid.

type InheritedLoggerOptions

type InheritedLoggerOptions struct {
	Base BaseOptions `json:"base" bson:"base"`
}

InheritedLoggerOptions encapsulates the options for creating a logger inherited from the globally-configured grip logger.

func (*InheritedLoggerOptions) Configure

func (opts *InheritedLoggerOptions) Configure() (send.Sender, error)

Configure returns a send.Sender based on the inherited logger options.

func (*InheritedLoggerOptions) Type

Type returns the log type for inherited loggers.

type LogFormat

type LogFormat string

LogFormat specifies a certain format for logging by Jasper. See the documentation for grip/send for more information on the various LogFormats.

const (
	LogFormatPlain   LogFormat = "plain"
	LogFormatDefault LogFormat = "default"
	LogFormatJSON    LogFormat = "json"
	LogFormatInvalid LogFormat = "invalid"
)

Constants representing formats for logging.

func (LogFormat) MakeFormatter

func (f LogFormat) MakeFormatter() (send.MessageFormatter, error)

MakeFormatter creates a grip/send.MessageFormatter for the specified LogFormat on which it is called.

func (LogFormat) Validate

func (f LogFormat) Validate() error

Validate ensures that the LogFormat is valid.

type LoggerConfig

type LoggerConfig struct {
	Registry LoggerRegistry
	// contains filtered or unexported fields
}

LoggerConfig represents the necessary information to construct a new grip send.Sender. The Registry is the authoritative source of LoggerProducers that it can use to create the send.Sender. LoggerConfig implements the JSON and BSON Marshaler and Unmarshaler interfaces.

func NewLoggerConfig

func NewLoggerConfig(producerType string, format RawLoggerConfigFormat, config []byte) *LoggerConfig

NewLoggerConfig returns a LoggerConfig with the given info. This function expects a raw logger config as a byte slice. If this logger config is meant to be used in-memory, (*LoggerConfig).Set must be called before it can be used.

func (*LoggerConfig) MarshalBSON

func (lc *LoggerConfig) MarshalBSON() ([]byte, error)

MarshalBSON resolves the LoggerProducer from this LoggerConfig, marshals it to BSON, and returns the logger configuration information necessary to reconstruct the LoggerConfig.

func (*LoggerConfig) MarshalJSON

func (lc *LoggerConfig) MarshalJSON() ([]byte, error)

MarshalJSON resolves the LoggerProducer from this LoggerConfig, marshals it to JSON, and returns the logger configuration information necessary to reconstruct the LoggerConfig.

func (*LoggerConfig) Producer

func (lc *LoggerConfig) Producer() LoggerProducer

Producer returns the underlying logger producer for this LoggerConfig, which may be nil.

func (*LoggerConfig) Resolve

func (lc *LoggerConfig) Resolve() (send.Sender, error)

Resolve resolves the LoggerConfig and returns the resulting grip send.Sender.

func (*LoggerConfig) Set

func (lc *LoggerConfig) Set(producer LoggerProducer) error

Set sets the logger producer and type for the LoggerConfig.

func (*LoggerConfig) Type

func (lc *LoggerConfig) Type() string

Type returns the type string.

func (*LoggerConfig) UnmarshalBSON

func (lc *LoggerConfig) UnmarshalBSON(b []byte) error

UnmarshalBSON unmarshals the logger configuration information necessary to reconstruct the LoggerConfig.

func (*LoggerConfig) UnmarshalJSON

func (lc *LoggerConfig) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the logger configuration necessary to reconstruct the LoggerConfig.

type LoggerProducer

type LoggerProducer interface {
	Type() string
	Configure() (send.Sender, error)
}

LoggerProducer produces a Logger interface backed by a grip logger.

func NewBuildloggerV2LoggerProducer

func NewBuildloggerV2LoggerProducer() LoggerProducer

NewBuildloggerV2LoggerProducer returns a LoggerProducer for creating Buildlogger v2 loggers.

func NewDefaultLoggerProducer

func NewDefaultLoggerProducer() LoggerProducer

NewDefaultLoggerProducer returns a LoggerProducer backed by DefaultLoggerOptions.

func NewFileLoggerProducer

func NewFileLoggerProducer() LoggerProducer

NewFileLoggerProducer returns a LoggerProducer backed by FileLoggerOptions.

func NewInMemoryLoggerProducer

func NewInMemoryLoggerProducer() LoggerProducer

NewInMemoryLoggerProducer returns a LoggerProducer for creating in-memory loggers.

func NewInheritedLoggerProducer

func NewInheritedLoggerProducer() LoggerProducer

NewInheritedLoggerProducer returns a LoggerProducer for creating inherited loggers.

func NewSplunkLoggerProducer

func NewSplunkLoggerProducer() LoggerProducer

NewSplunkLoggerProducer returns a LoggerProducer for creating Splunk loggers.

type LoggerProducerFactory

type LoggerProducerFactory func() LoggerProducer

LoggerProducerFactory creates a new instance of a LoggerProducer implementation.

type LoggerRegistry

type LoggerRegistry interface {
	Register(LoggerProducerFactory)
	Check(string) bool
	Names() []string
	Resolve(string) (LoggerProducerFactory, bool)
}

LoggerRegistry is an interface that stores reusable logger factories.

func GetGlobalLoggerRegistry

func GetGlobalLoggerRegistry() LoggerRegistry

GetGlobalLoggerRegistry returns the global logger registry.

func NewBasicLoggerRegistry

func NewBasicLoggerRegistry() LoggerRegistry

NewBasicLoggerRegistry returns a new LoggerRegistry implementation.

type LoggingPayload

type LoggingPayload struct {
	LoggerID          string               `bson:"logger_id" json:"logger_id" yaml:"logger_id"`
	Data              interface{}          `bson:"data" json:"data" yaml:"data"`
	Priority          level.Priority       `bson:"priority" json:"priority" yaml:"priority"`
	IsMulti           bool                 `bson:"multi,omitempty" json:"multi,omitempty" yaml:"multi,omitempty"`
	PreferSendToError bool                 `bson:"prefer_send_to_error,omitempty" json:"prefer_send_to_error,omitempty" yaml:"prefer_send_to_error,omitempty"`
	AddMetadata       bool                 `bson:"add_metadata,omitempty" json:"add_metadata,omitempty" yaml:"add_metadata,omitempty"`
	Format            LoggingPayloadFormat `bson:"payload_format,omitempty" json:"payload_format,omitempty" yaml:"payload_format,omitempty"`
}

LoggingPayload captures the arguments to the SendMessages operation.

func (*LoggingPayload) Validate

func (lp *LoggingPayload) Validate() error

Validate checks that the required fields are populated for the payload and the format is valid.

type LoggingPayloadFormat

type LoggingPayloadFormat string

LoggingPayloadFormat is an set enumerated values describing the formating or encoding of the payload data.

type MongoDBDownload

type MongoDBDownload struct {
	BuildOpts bond.BuildOptions `json:"build_opts"`
	Path      string            `json:"path"`
	Releases  []string          `json:"releases"`
}

MongoDBDownload represents the options to download MongoDB on a target platform.

func (MongoDBDownload) Validate

func (opts MongoDBDownload) Validate() error

Validate checks for valid MongoDB download options.

type Output

type Output struct {
	Output            io.Writer `bson:"-" json:"-" yaml:"-"`
	Error             io.Writer `bson:"-" json:"-" yaml:"-"`
	SuppressOutput    bool      `bson:"suppress_output" json:"suppress_output" yaml:"suppress_output"`
	SuppressError     bool      `bson:"suppress_error" json:"suppress_error" yaml:"suppress_error"`
	SendOutputToError bool      `bson:"redirect_output_to_error" json:"redirect_output_to_error" yaml:"redirect_output_to_error"`
	SendErrorToOutput bool      `bson:"redirect_error_to_output" json:"redirect_error_to_output" yaml:"redirect_error_to_output"`
	// Loggers are self-contained and specific to the process they are attached
	// to. They are closed and cleaned up when the process exits. If this
	// behavior is not desired, use Output instead of Loggers.
	Loggers []*LoggerConfig `bson:"loggers" json:"loggers,omitempty" yaml:"loggers"`
	// contains filtered or unexported fields
}

Output provides a common way to define and represent the output behavior of a evergreen/subprocess.Command operation.

func (*Output) CachedLogger

func (o *Output) CachedLogger(id string) *CachedLogger

CachedLogger returns a cached logger with the given ID with its error and output derived from Output.

func (*Output) Close

func (o *Output) Close() error

Close calls all of the processes' output senders' Close method.

func (*Output) Copy

func (o *Output) Copy() *Output

Copy returns a copy of the options for only the exported fields. Unexported fields are cleared.

func (*Output) GetError

func (o *Output) GetError() (io.Writer, error)

GetError returns an io.Writer that can be used for standard error, depending on the output configuration.

func (*Output) GetOutput

func (o *Output) GetOutput() (io.Writer, error)

GetOutput returns a Writer that has the stdout output from the process that the Output that this method is called on is attached to. The caller is responsible for calling Close when the loggers are not needed anymore.

func (*Output) Validate

func (o *Output) Validate() error

Validate ensures that the Output it is called on has reasonable values.

type Proxy

type Proxy struct {
	RemoteConfig
}

Proxy represents the remote configuration to access a remote proxy machine.

func (*Proxy) Copy

func (opts *Proxy) Copy() *Proxy

Copy returns a copy of the options for only the exported fields.

type RawLoggerConfig

type RawLoggerConfig []byte

RawLoggerConfig wraps byte slice and implements the json and bson Marshaler and Unmarshaler interfaces.

func (RawLoggerConfig) MarshalBSON

func (lc RawLoggerConfig) MarshalBSON() ([]byte, error)

MarshalBSON returns the unwrapped byte slice from the RawLoggerConfig.

func (*RawLoggerConfig) MarshalJSON

func (lc *RawLoggerConfig) MarshalJSON() ([]byte, error)

MarshalJSON returns the unwrapped byte slice from a RawLoggerConfig.

func (*RawLoggerConfig) UnmarshalBSON

func (lc *RawLoggerConfig) UnmarshalBSON(b []byte) error

UnmarshalBSON sets the unwrapped byte slice to the given BSON byte slice.

func (*RawLoggerConfig) UnmarshalJSON

func (lc *RawLoggerConfig) UnmarshalJSON(b []byte) error

UnmarshalJSON sets the wrapped byte slice to the given byte slice.

type RawLoggerConfigFormat

type RawLoggerConfigFormat string

RawLoggerConfigFormat describes the format of the raw logger configuration.

const (
	RawLoggerConfigFormatBSON    RawLoggerConfigFormat = "BSON"
	RawLoggerConfigFormatJSON    RawLoggerConfigFormat = "JSON"
	RawLoggerConfigFormatInvalid RawLoggerConfigFormat = "invalid"
)

Constants representing valid formats for RawLoggerConfig.

func (RawLoggerConfigFormat) Unmarshal

func (f RawLoggerConfigFormat) Unmarshal(data []byte, out interface{}) error

Unmarshal unmarshals the given data using the corresponding unmarshaler for the RawLoggerConfigFormat type.

func (RawLoggerConfigFormat) Validate

func (f RawLoggerConfigFormat) Validate() error

Validate ensures that RawLoggerConfigFormat is valid.

type Remote

type Remote struct {
	RemoteConfig
	Proxy *Proxy
}

Remote represents options to SSH into a remote machine.

func (*Remote) Copy

func (opts *Remote) Copy() *Remote

Copy returns a copy of the options for only the exported fields.

func (*Remote) Resolve

func (opts *Remote) Resolve() (*ssh.Client, *ssh.Session, error)

Resolve returns the SSH client and session from the options.

func (*Remote) String

func (opts *Remote) String() string

func (*Remote) Validate

func (opts *Remote) Validate() error

Validate ensures that enough information is provided to connect to a remote host.

type RemoteConfig

type RemoteConfig struct {
	Host string `bson:"host" json:"host"`
	User string `bson:"user" json:"user"`

	// Args to the SSH binary. Only used by if UseSSHLibrary is false.
	Args []string `bson:"args,omitempty" json:"args,omitempty"`

	// Determines whether to use the SSH binary or the SSH library.
	UseSSHLibrary bool `bson:"use_ssh_library,omitempty" json:"use_ssh_library,omitempty"`

	// The following apply only if UseSSHLibrary is true.
	Port          int    `bson:"port,omitempty" json:"port,omitempty"`
	Key           string `bson:"key,omitempty" json:"key,omitempty"`
	KeyFile       string `bson:"key_file,omitempty" json:"key_file,omitempty"`
	KeyPassphrase string `bson:"key_passphrase,omitempty" json:"key_passphrase,omitempty"`
	Password      string `bson:"password,omitempty" json:"password,omitempty"`
	// Connection timeout
	Timeout time.Duration `bson:"timeout,omitempty" json:"timeout,omitempty"`
}

RemoteConfig represents the arguments to connect to a remote host.

type SafeSender

type SafeSender struct {
	send.Sender
	// contains filtered or unexported fields
}

SafeSender wraps a grip send.Sender and its base sender, ensuring that the base sender is closed correctly.

func (*SafeSender) Close

func (s *SafeSender) Close() error

Close closes all underlying send.Senders to provide a stronger guarantee on closing its underlying send.Senders to free the resources. This resolves an issue in some send.Sender implementations (particularly the buffered sender) where send.Senders that wrap other senders are not guaranteed to close the send.Sender that they wrap, which can be a resource leak.

func (*SafeSender) GetSender

func (s *SafeSender) GetSender() send.Sender

GetSender returns the underlying base grip send.Sender.

type SplunkLoggerOptions

type SplunkLoggerOptions struct {
	Splunk send.SplunkConnectionInfo `json:"splunk" bson:"splunk"`
	Base   BaseOptions               `json:"base" bson:"base"`
}

SplunkLoggerOptions encapsulates the options for creating a Splunk logger.

func (*SplunkLoggerOptions) Configure

func (opts *SplunkLoggerOptions) Configure() (send.Sender, error)

Configure returns a send.Sender based on the Splunk options.

func (*SplunkLoggerOptions) Type

func (*SplunkLoggerOptions) Type() string

Type returns the log type for Splunk.

func (*SplunkLoggerOptions) Validate

func (opts *SplunkLoggerOptions) Validate() error

Validate checks that the Splunk options are populated and that the common base options are valid.

type WriteFile

type WriteFile struct {
	Path string `json:"path" bson:"path"`
	// File content can come from either Content or Reader, but not both.
	// Content should only be used if the entire file's contents can be held in
	// memory.
	Content []byte      `json:"content" bson:"content"`
	Reader  io.Reader   `json:"-" bson:"-"`
	Append  bool        `json:"append" bson:"append"`
	Perm    os.FileMode `json:"perm" bson:"perm"`
}

WriteFile represents the options necessary to write to a file.

func (*WriteFile) ContentReader

func (opts *WriteFile) ContentReader() (io.Reader, error)

ContentReader returns the contents to be written to the file as an io.Reader.

func (*WriteFile) DoWrite

func (opts *WriteFile) DoWrite() error

DoWrite writes the data to the given path, creating the directory hierarchy as needed and the file if it does not exist yet.

func (*WriteFile) SetPerm

func (opts *WriteFile) SetPerm() error

SetPerm sets the file permissions on the file. This should be called after DoWrite. If no file exists at (WriteFile).Path, it will error.

func (*WriteFile) Validate

func (opts *WriteFile) Validate() error

Validate ensures that all the parameters to write to a file are valid and sets default permissions if necessary.

func (*WriteFile) WriteBufferedContent

func (opts *WriteFile) WriteBufferedContent(doWrite func(bufopts WriteFile) error) error

WriteBufferedContent writes the content to a file by repeatedly calling doWrite with a buffered portion of the content. doWrite processes the WriteFile containing the next content to write to the file.

Jump to

Keyboard shortcuts

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