...

Package machineoutput

Overview ▾

Index ▾

Constants
func FormatTime(time time.Time) string
func OutputError(machineOutput interface{})
func OutputSuccess(stdout, stderr io.Writer, machineOutput interface{})
func OutputSuccessUnindented(machineOutput interface{})
func TimestampNow() string
type AbstractLogEvent
    func (c AbstractLogEvent) GetTimestamp() string
type ConsoleMachineEventLoggingClient
    func NewConsoleMachineEventLoggingClient() *ConsoleMachineEventLoggingClient
    func (c *ConsoleMachineEventLoggingClient) ContainerStatus(statuses []ContainerStatusEntry, timestamp string)
    func (c *ConsoleMachineEventLoggingClient) CreateContainerOutputWriter() (*io.PipeWriter, chan interface{}, *io.PipeWriter, chan interface{})
    func (c *ConsoleMachineEventLoggingClient) DevFileCommandExecutionBegin(commandID string, componentName string, commandLine string, groupKind string, timestamp string)
    func (c *ConsoleMachineEventLoggingClient) DevFileCommandExecutionComplete(commandID string, componentName string, commandLine string, groupKind string, timestamp string, errorVal error)
    func (c *ConsoleMachineEventLoggingClient) KubernetesPodStatus(pods []KubernetesPodStatusEntry, timestamp string)
    func (c *ConsoleMachineEventLoggingClient) ReportError(errorVal error, timestamp string)
    func (c *ConsoleMachineEventLoggingClient) URLReachable(name string, url string, port int, secure bool, kind string, reachable bool, timestamp string)
type ContainerStatus
    func (c ContainerStatus) GetType() MachineEventLogEntryType
type ContainerStatusEntry
type DevFileCommandExecutionBegin
    func (c DevFileCommandExecutionBegin) GetType() MachineEventLogEntryType
type DevFileCommandExecutionComplete
    func (c DevFileCommandExecutionComplete) GetType() MachineEventLogEntryType
type KubernetesPodStatus
    func (c KubernetesPodStatus) GetType() MachineEventLogEntryType
type KubernetesPodStatusEntry
type LogText
    func (c LogText) GetType() MachineEventLogEntryType
type MachineEventLogEntry
type MachineEventLogEntryType
type MachineEventLoggingClient
    func NewMachineEventLoggingClient() MachineEventLoggingClient
type MachineEventWrapper
    func (w MachineEventWrapper) GetEntry() (MachineEventLogEntry, error)
type NoOpMachineEventLoggingClient
    func NewNoOpMachineEventLoggingClient() *NoOpMachineEventLoggingClient
    func (c *NoOpMachineEventLoggingClient) ContainerStatus(statuses []ContainerStatusEntry, timestamp string)
    func (c *NoOpMachineEventLoggingClient) CreateContainerOutputWriter() (*io.PipeWriter, chan interface{}, *io.PipeWriter, chan interface{})
    func (c *NoOpMachineEventLoggingClient) DevFileCommandExecutionBegin(commandID string, componentName string, commandLine string, groupKind string, timestamp string)
    func (c *NoOpMachineEventLoggingClient) DevFileCommandExecutionComplete(commandID string, componentName string, commandLine string, groupKind string, timestamp string, errorVal error)
    func (c *NoOpMachineEventLoggingClient) KubernetesPodStatus(pods []KubernetesPodStatusEntry, timestamp string)
    func (c *NoOpMachineEventLoggingClient) ReportError(errorVal error, timestamp string)
    func (c *NoOpMachineEventLoggingClient) URLReachable(name string, url string, port int, secure bool, kind string, reachable bool, timestamp string)
type RegistryListOutput
    func NewRegistryListOutput(registryList *[]preference.Registry) RegistryListOutput
type ReportError
    func (c ReportError) GetType() MachineEventLogEntryType
type URLReachable
    func (c URLReachable) GetType() MachineEventLogEntryType

Package files

event_logging.go registry.go types.go types_event_logging.go

Constants

APIVersion is the current API version used in the machine readable output

const APIVersion = "odo.dev/v1alpha1"

ListKind is the kind used for all lists in the machine readable output

const ListKind = "List"

func FormatTime

func FormatTime(time time.Time) string

FormatTime returns time in UTC Unix Epoch Seconds and then the microsecond portion of that time.

func OutputError

func OutputError(machineOutput interface{})

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

func OutputSuccess

func OutputSuccess(stdout, stderr io.Writer, machineOutput interface{})

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

func OutputSuccessUnindented

func OutputSuccessUnindented(machineOutput interface{})

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

func TimestampNow

func TimestampNow() string

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

type AbstractLogEvent

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

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

func (AbstractLogEvent) GetTimestamp

func (c AbstractLogEvent) GetTimestamp() string

GetTimestamp returns the timestamp element for this event.

type ConsoleMachineEventLoggingClient

ConsoleMachineEventLoggingClient will output all events to the console as JSON

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

func NewConsoleMachineEventLoggingClient

func NewConsoleMachineEventLoggingClient() *ConsoleMachineEventLoggingClient

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

func (*ConsoleMachineEventLoggingClient) ContainerStatus

func (c *ConsoleMachineEventLoggingClient) ContainerStatus(statuses []ContainerStatusEntry, timestamp string)

ContainerStatus outputs the provided event as JSON to the console.

func (*ConsoleMachineEventLoggingClient) CreateContainerOutputWriter

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

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

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) KubernetesPodStatus

func (c *ConsoleMachineEventLoggingClient) KubernetesPodStatus(pods []KubernetesPodStatusEntry, timestamp string)

KubernetesPodStatus outputs the provided event as JSON to the console.

func (*ConsoleMachineEventLoggingClient) ReportError

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

ReportError outputs the provided event as JSON to the console.

func (*ConsoleMachineEventLoggingClient) URLReachable

func (c *ConsoleMachineEventLoggingClient) URLReachable(name string, url string, port int, secure bool, kind string, reachable bool, timestamp string)

URLReachable outputs the provided event as JSON to the console.

type ContainerStatus

ContainerStatus is the JSON event that is emitted to indicate odo-managed Docker container status

type ContainerStatus struct {
    Status []ContainerStatusEntry `json:"status"`
    AbstractLogEvent
}

func (ContainerStatus) GetType

func (c ContainerStatus) GetType() MachineEventLogEntryType

GetType returns the event type for this event.

type ContainerStatusEntry

ContainerStatusEntry is an individual container's status

type ContainerStatusEntry struct {
    ID     string `json:"id"`
    Status string `json:"status"`
}

type DevFileCommandExecutionBegin

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

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

func (DevFileCommandExecutionBegin) GetType

func (c DevFileCommandExecutionBegin) GetType() MachineEventLogEntryType

GetType returns the event type for this event.

type DevFileCommandExecutionComplete

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

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

func (DevFileCommandExecutionComplete) GetType

func (c DevFileCommandExecutionComplete) GetType() MachineEventLogEntryType

GetType returns the event type for this event.

type KubernetesPodStatus

KubernetesPodStatus is the JSON event that emitted to indicate the status of pods in an odo-managed deployment

type KubernetesPodStatus struct {
    Pods []KubernetesPodStatusEntry `json:"pods"`
    AbstractLogEvent
}

func (KubernetesPodStatus) GetType

func (c KubernetesPodStatus) GetType() MachineEventLogEntryType

GetType returns the event type for this event.

type KubernetesPodStatusEntry

KubernetesPodStatusEntry is an individual pod's information

type KubernetesPodStatusEntry struct {
    Name           string                   `json:"name"`
    UID            string                   `json:"uid"`
    Phase          string                   `json:"phase"`
    Labels         map[string]string        `json:"labels,omitempty"`
    StartTime      string                   `json:"startTime,omitempty"`
    Containers     []corev1.ContainerStatus `json:"containers"`
    InitContainers []corev1.ContainerStatus `json:"initContainers"`
}

type LogText

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

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

func (LogText) GetType

func (c LogText) GetType() MachineEventLogEntryType

GetType returns the event type for this event.

type MachineEventLogEntry

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

type MachineEventLogEntry interface {
    GetTimestamp() string
}

type MachineEventLogEntryType

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

type MachineEventLogEntryType int
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
    // TypeContainerStatus is the entry type for that event.
    TypeContainerStatus MachineEventLogEntryType = 5
    // TypeURLReachable is the entry type for that event.
    TypeURLReachable MachineEventLogEntryType = 6
    // TypeKubernetesPodStatus is the entry type for that event.
    TypeKubernetesPodStatus MachineEventLogEntryType = 7
)

type MachineEventLoggingClient

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.

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)

    ContainerStatus(statuses []ContainerStatusEntry, timestamp string)

    URLReachable(name string, url string, port int, secure bool, kind string, reachable bool, timestamp string)

    KubernetesPodStatus(pods []KubernetesPodStatusEntry, 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{})
}

func NewMachineEventLoggingClient

func NewMachineEventLoggingClient() MachineEventLoggingClient

NewMachineEventLoggingClient creates the appropriate client based on whether we are in machine logging mode or not

type MachineEventWrapper

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.

type MachineEventWrapper struct {
    DevFileCommandExecutionBegin    *DevFileCommandExecutionBegin    `json:"devFileCommandExecutionBegin,omitempty"`
    DevFileCommandExecutionComplete *DevFileCommandExecutionComplete `json:"devFileCommandExecutionComplete,omitempty"`
    LogText                         *LogText                         `json:"logText,omitempty"`
    ReportError                     *ReportError                     `json:"reportError,omitempty"`
    ContainerStatus                 *ContainerStatus                 `json:"containerStatus,omitempty"`
    URLReachable                    *URLReachable                    `json:"urlReachable,omitempty"`
    KubernetesPodStatus             *KubernetesPodStatus             `json:"kubernetesPodStatus,omitempty"`
}

func (MachineEventWrapper) GetEntry

func (w MachineEventWrapper) GetEntry() (MachineEventLogEntry, error)

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

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

type NoOpMachineEventLoggingClient struct {
}

func NewNoOpMachineEventLoggingClient

func NewNoOpMachineEventLoggingClient() *NoOpMachineEventLoggingClient

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

func (*NoOpMachineEventLoggingClient) ContainerStatus

func (c *NoOpMachineEventLoggingClient) ContainerStatus(statuses []ContainerStatusEntry, timestamp string)

ContainerStatus ignores the provided event.

func (*NoOpMachineEventLoggingClient) CreateContainerOutputWriter

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

CreateContainerOutputWriter ignores the provided event.

func (*NoOpMachineEventLoggingClient) DevFileCommandExecutionBegin

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

DevFileCommandExecutionBegin ignores the provided event.

func (*NoOpMachineEventLoggingClient) DevFileCommandExecutionComplete

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

DevFileCommandExecutionComplete ignores the provided event.

func (*NoOpMachineEventLoggingClient) KubernetesPodStatus

func (c *NoOpMachineEventLoggingClient) KubernetesPodStatus(pods []KubernetesPodStatusEntry, timestamp string)

KubernetesPodStatus ignores the provided event.

func (*NoOpMachineEventLoggingClient) ReportError

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

ReportError ignores the provided event.

func (*NoOpMachineEventLoggingClient) URLReachable

func (c *NoOpMachineEventLoggingClient) URLReachable(name string, url string, port int, secure bool, kind string, reachable bool, timestamp string)

URLReachable ignores the provided event.

type RegistryListOutput

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

func NewRegistryListOutput

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

type ReportError

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

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

func (ReportError) GetType

func (c ReportError) GetType() MachineEventLogEntryType

GetType returns the event type for this event.

type URLReachable

URLReachable is the JSON event that is emitted to indicate whether one of the component's URL's could be reached.

type URLReachable struct {
    Name      string `json:"name"`
    URL       string `json:"url"`
    Port      int    `json:"port"`
    Secure    bool   `json:"secure"`
    Kind      string `json:"kind"`
    Reachable bool   `json:"reachable"`
    AbstractLogEvent
}

func (URLReachable) GetType

func (c URLReachable) GetType() MachineEventLogEntryType

GetType returns the event type for this event.