machineoutput

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 11 Imported by: 103

Documentation

Index

Constants

View Source
const APIVersion = "odo.dev/v1alpha1"

APIVersion is the current API version we are using

View Source
const Kind = "Error"

Kind is what kind we should use in the machine readable output

Variables

This section is empty.

Functions

func GetCommandName added in v1.2.3

func GetCommandName(entry MachineEventLogEntry) string

GetCommandName returns a command if the MLE supports that field (otherwise empty string is returned). Currently used for test purposes only.

func OutputError

func OutputError(machineOutput interface{})

OutputError outputs a "successful" machine-readable output format in json

func OutputSuccess

func OutputSuccess(machineOutput interface{})

OutputSuccess outputs a "successful" machine-readable output format in json

func OutputSuccessUnindented added in v1.2.3

func OutputSuccessUnindented(machineOutput interface{})

OutputSuccessUnindented outputs a "successful" machine-readable output format in unindented json

func TimestampNow added in v1.2.3

func TimestampNow() string

TimestampNow returns timestamp in format of (seconds since UTC Unix epoch).(microseconds time component)

Types

type AbstractLogEvent added in v1.2.3

type AbstractLogEvent struct {
	Timestamp string `json:"timestamp"`
}

AbstractLogEvent is the base struct for all events; all events must at a minimum contain a timestamp.

func (AbstractLogEvent) GetTimestamp added in v1.2.3

func (c AbstractLogEvent) GetTimestamp() string

GetTimestamp returns the timestamp element for this event.

type ConsoleMachineEventLoggingClient added in v1.2.3

type ConsoleMachineEventLoggingClient struct {
}

ConsoleMachineEventLoggingClient will output all events to the console as JSON

func NewConsoleMachineEventLoggingClient added in v1.2.3

func NewConsoleMachineEventLoggingClient() *ConsoleMachineEventLoggingClient

NewConsoleMachineEventLoggingClient creates a new instance of ConsoleMachineEventLoggingClient, which will output events as JSON to the console.

func (*ConsoleMachineEventLoggingClient) CreateContainerOutputWriter added in v1.2.3

func (c *ConsoleMachineEventLoggingClient) CreateContainerOutputWriter() (*io.PipeWriter, chan interface{}, *io.PipeWriter, chan interface{})

CreateContainerOutputWriter returns an io.PipeWriter for which the devfile command/action process output should be written (for example by passing the io.PipeWriter to exec.ExecuteCommand), and a channel for communicating when the last data has been received on the reader.

All text written to the returned object will be output as a log text event. Returned channels will each contain a single nil entry once the underlying reader has closed.

func (*ConsoleMachineEventLoggingClient) DevFileCommandExecutionBegin added in v1.2.3

func (c *ConsoleMachineEventLoggingClient) DevFileCommandExecutionBegin(commandID string, componentName string, commandLine string, groupKind string, timestamp string)

DevFileCommandExecutionBegin outputs the provided event as JSON to the console.

func (*ConsoleMachineEventLoggingClient) DevFileCommandExecutionComplete added in v1.2.3

func (c *ConsoleMachineEventLoggingClient) DevFileCommandExecutionComplete(commandID string, componentName string, commandLine string, groupKind string, timestamp string, errorVal error)

DevFileCommandExecutionComplete outputs the provided event as JSON to the console.

func (*ConsoleMachineEventLoggingClient) ReportError added in v1.2.3

func (c *ConsoleMachineEventLoggingClient) ReportError(errorVal error, timestamp string)

ReportError ignores the provided event.

type DevFileCommandExecutionBegin added in v1.2.3

type DevFileCommandExecutionBegin struct {
	CommandID     string `json:"commandId"`
	ComponentName string `json:"componentName"`
	CommandLine   string `json:"commandLine"`
	GroupKind     string `json:"groupKind"`
	AbstractLogEvent
}

DevFileCommandExecutionBegin is the JSON event that is emitted when a dev file command begins execution.

func (DevFileCommandExecutionBegin) GetType added in v1.2.3

GetType returns the event type for this event.

type DevFileCommandExecutionComplete added in v1.2.3

type DevFileCommandExecutionComplete struct {
	DevFileCommandExecutionBegin
	Error string `json:"error,omitempty"`
}

DevFileCommandExecutionComplete is the JSON event that is emitted when a dev file command completes execution.

func (DevFileCommandExecutionComplete) GetType added in v1.2.3

GetType returns the event type for this event.

type GenericError

type GenericError struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Message           string `json:"message"`
}

GenericError for machine readable output error messages

type GenericSuccess

type GenericSuccess struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Message           string `json:"message"`
}

GenericSuccess same as above, but copy-and-pasted just in case we change the output in the future

type LogText added in v1.2.3

type LogText struct {
	Text   string `json:"text"`
	Stream string `json:"stream"`
	AbstractLogEvent
}

LogText is the JSON event that is emitted when a dev file action outputs text to the console.

func (LogText) GetType added in v1.2.3

func (c LogText) GetType() MachineEventLogEntryType

GetType returns the event type for this event.

type MachineEventLogEntry added in v1.2.3

type MachineEventLogEntry interface {
	GetTimestamp() string
	GetType() MachineEventLogEntryType
}

MachineEventLogEntry contains the expected methods for every event that is emitted. (This is mainly used for test purposes.)

type MachineEventLogEntryType added in v1.2.3

type MachineEventLogEntryType int

MachineEventLogEntryType indicates the machine-readable event type from an ODO operation

const (
	// TypeDevFileCommandExecutionBegin is the entry type for that event.
	TypeDevFileCommandExecutionBegin MachineEventLogEntryType = 0
	// TypeDevFileCommandExecutionComplete is the entry type for that event.
	TypeDevFileCommandExecutionComplete MachineEventLogEntryType = 1
	// TypeLogText is the entry type for that event.
	TypeLogText MachineEventLogEntryType = 2
	// TypeReportError is the entry type for that event.
	TypeReportError MachineEventLogEntryType = 3
)

type MachineEventLoggingClient added in v1.2.3

type MachineEventLoggingClient interface {
	DevFileCommandExecutionBegin(commandID string, componentName string, commandLine string, groupKind string, timestamp string)
	DevFileCommandExecutionComplete(commandID string, componentName string, commandLine string, groupKind string, timestamp string, errorVal error)
	ReportError(errorVal error, timestamp string)

	// CreateContainerOutputWriter is used to capture output from container processes, and synchronously write it to the screen as LogText. See implementation comments for details.
	CreateContainerOutputWriter() (*io.PipeWriter, chan interface{}, *io.PipeWriter, chan interface{})
}

MachineEventLoggingClient is an interface which is used by consuming code to output machine-readable event JSON to the console. Both no-op and non-no-op implementations of this interface exist.

func NewMachineEventLoggingClient added in v1.2.6

func NewMachineEventLoggingClient() MachineEventLoggingClient

type MachineEventWrapper added in v1.2.3

type MachineEventWrapper struct {
	DevFileCommandExecutionBegin    *DevFileCommandExecutionBegin    `json:"devFileCommandExecutionBegin,omitempty"`
	DevFileCommandExecutionComplete *DevFileCommandExecutionComplete `json:"devFileCommandExecutionComplete,omitempty"`
	LogText                         *LogText                         `json:"logText,omitempty"`
	ReportError                     *ReportError                     `json:"reportError,omitempty"`
}

MachineEventWrapper - a single line of machine-readable event console output must contain only one of these commands; the MachineEventWrapper is used to create (and parse, for tests) these lines.

func (MachineEventWrapper) GetEntry added in v1.2.3

GetEntry will return the JSON event parsed from a single line of '-o json' machine readable console output. Currently used for test purposes only.

type NoOpMachineEventLoggingClient added in v1.2.3

type NoOpMachineEventLoggingClient struct {
}

NoOpMachineEventLoggingClient will ignore (eg not output) all events passed to it

func NewNoOpMachineEventLoggingClient added in v1.2.3

func NewNoOpMachineEventLoggingClient() *NoOpMachineEventLoggingClient

NewNoOpMachineEventLoggingClient creates a new instance of NoOpMachineEventLoggingClient, which will ignore any provided events.

func (*NoOpMachineEventLoggingClient) CreateContainerOutputWriter added in v1.2.3

func (c *NoOpMachineEventLoggingClient) CreateContainerOutputWriter() (*io.PipeWriter, chan interface{}, *io.PipeWriter, chan interface{})

CreateContainerOutputWriter ignores the provided event.

func (*NoOpMachineEventLoggingClient) DevFileCommandExecutionBegin added in v1.2.3

func (c *NoOpMachineEventLoggingClient) DevFileCommandExecutionBegin(commandID string, componentName string, commandLine string, groupKind string, timestamp string)

DevFileCommandExecutionBegin ignores the provided event.

func (*NoOpMachineEventLoggingClient) DevFileCommandExecutionComplete added in v1.2.3

func (c *NoOpMachineEventLoggingClient) DevFileCommandExecutionComplete(commandID string, componentName string, commandLine string, groupKind string, timestamp string, errorVal error)

DevFileCommandExecutionComplete ignores the provided event.

func (*NoOpMachineEventLoggingClient) ReportError added in v1.2.3

func (c *NoOpMachineEventLoggingClient) ReportError(errorVal error, timestamp string)

ReportError ignores the provided event.

type RegistryListOutput added in v1.2.6

type RegistryListOutput struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	RegistryList      *[]preference.Registry `json:"registries,omitempty"`
}

func NewRegistryListOutput added in v1.2.6

func NewRegistryListOutput(registryList *[]preference.Registry) RegistryListOutput

type ReportError added in v1.2.3

type ReportError struct {
	Error string `json:"error"`
	AbstractLogEvent
}

ReportError is the JSON event that is emitted when an error occurs during push command

func (ReportError) GetType added in v1.2.3

GetType returns the event type for this event.

Jump to

Keyboard shortcuts

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