printer

package
v1.17.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFlowType

func GetFlowType(f *flowpb.Flow) string

GetFlowType returns the type of a flow as a string.

Types

type Option

type Option func(*Options)

Option ...

func Compact

func Compact() Option

Compact ...

func Dict

func Dict() Option

Dict ...

func IgnoreStderr

func IgnoreStderr() Option

IgnoreStderr configures the output to not print any

func JSONLegacy

func JSONLegacy() Option

JSONLegacy encoded output from the printer.

func JSONPB

func JSONPB() Option

JSONPB encodes GetFlowsResponse as JSON according to proto3's JSON mapping.

func Tab

func Tab() Option

Tab prints flows in even tab-aligned columns.

func WithColor

func WithColor(when string) Option

WithColor set the color mode. The when argument is one of:

  • "auto": color mode is enabled when the standard output is connected to a terminal.
  • "always": color mode is enabled no matter to standard output.
  • "never": color mode is always disabled.

Any other value of when means "auto", which is the default. The color mode is only applied with in Dict or Compact mode. For any other mode, color is always disabled.

func WithDebug

func WithDebug() Option

WithDebug enables debug messages

func WithIPTranslation

func WithIPTranslation() Option

WithIPTranslation enables translation from IPs to pod names, FQDNs, and service names.

func WithNodeName

func WithNodeName() Option

WithNodeName enables printing the node name.

func WithTimeFormat

func WithTimeFormat(layout string) Option

WithTimeFormat specifies the time format layout to use when printing out timestamps. This option has no effect if JSONLegacy or JSONPB option is used. The layout must be a time format layout as specified in the standard library's time package.

func Writer

func Writer(w io.Writer) Option

Writer sets the custom destination for where the bytes are sent.

type Options

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

Options for the printer.

type Output

type Output int

Output enum of the printer.

const (
	// TabOutput prints flows in even tab-aligned columns.
	TabOutput Output = iota
	// JSONLegacyOutput prints flows as json in the legacy format
	JSONLegacyOutput
	// CompactOutput prints flows as compact as possible (similar to monitor).
	CompactOutput
	// DictOutput presents the same information as TabOutput, but each flow is
	// presented as a key:value dictionary, similar to \G output of mysql.
	DictOutput
	// JSONPBOutput prints GetFlowsResponse as JSON according to proto3's JSON mapping.
	JSONPBOutput
)

type Printer

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

Printer for flows.

func New

func New(fopts ...Option) *Printer

New Printer.

func (*Printer) Close

func (p *Printer) Close() error

Close any outstanding operations going on in the printer.

func (*Printer) GetHostNames

func (p *Printer) GetHostNames(f *flowpb.Flow) (string, string)

GetHostNames returns source and destination hostnames of a flow.

func (*Printer) GetPorts

func (p *Printer) GetPorts(f *flowpb.Flow) (string, string)

GetPorts returns source and destination port of a flow.

func (*Printer) GetSecurityIdentities

func (p *Printer) GetSecurityIdentities(f *flowpb.Flow) (srcIdentity, dstIdentity string)

GetSecurityIdentities returns the source and destination numeric security identity formatted as a string.

func (*Printer) Hostname

func (p *Printer) Hostname(ip, port string, ns, pod, svc string, names []string) (host string)

Hostname returns a "host:ip" formatted pair for the given ip and port. If port is empty, only the host is returned. The host part is either the pod or service name (if set), or a comma-separated list of domain names (if set), or just the ip address if EnableIPTranslation is false and/or there are no pod nor service name and domain names.

func (*Printer) WriteErr

func (p *Printer) WriteErr(msg string) error

WriteErr returns the given msg into the err writer defined in the printer.

func (*Printer) WriteGetFlowsResponse

func (p *Printer) WriteGetFlowsResponse(res *observerpb.GetFlowsResponse) error

WriteGetFlowsResponse prints GetFlowsResponse according to the printer configuration.

func (*Printer) WriteLostEvent added in v1.16.3

func (p *Printer) WriteLostEvent(res *observerpb.GetFlowsResponse) error

WriteLostEvent writes v1.Flow into the output writer.

func (*Printer) WriteProtoAgentEvent

func (p *Printer) WriteProtoAgentEvent(r *observerpb.GetAgentEventsResponse) error

WriteProtoAgentEvent writes v1.AgentEvent into the output writer.

func (*Printer) WriteProtoDebugEvent

func (p *Printer) WriteProtoDebugEvent(r *observerpb.GetDebugEventsResponse) error

WriteProtoDebugEvent writes a flowpb.DebugEvent into the output writer.

func (*Printer) WriteProtoFlow

func (p *Printer) WriteProtoFlow(res *observerpb.GetFlowsResponse) error

WriteProtoFlow writes v1.Flow into the output writer.

func (*Printer) WriteProtoNodeStatusEvent

func (p *Printer) WriteProtoNodeStatusEvent(r *observerpb.GetFlowsResponse) error

WriteProtoNodeStatusEvent writes a node status event into the error stream

func (*Printer) WriteServerStatusResponse

func (p *Printer) WriteServerStatusResponse(res *observerpb.ServerStatusResponse) error

WriteServerStatusResponse writes server status response into the output writer.

Jump to

Keyboard shortcuts

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