encoder

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidEvent       = errors.New("invalid event")
	ErrMissingProcessInfo = errors.New("process field is not set")
	ErrUnknownEventType   = errors.New("unknown event type")
)
View Source
var (
	CLONE_NEWCGROUP = 0x2000000
	CLONE_NEWIPC    = 0x8000000
	CLONE_NEWNET    = 0x40000000
	CLONE_NEWNS     = 0x20000
	CLONE_NEWPID    = 0x20000000
	CLONE_NEWTIME   = 0x80
	CLONE_NEWUSER   = 0x10000000
	CLONE_NEWUTS    = 0x4000000
)

Functions

func CapTrailorPrinter

func CapTrailorPrinter(str string, caps string) string

func PrintNS

func PrintNS(ns int32) string

Types

type ColorMode

type ColorMode string

ColorMode defines color mode flags for compact output.

const (
	Always ColorMode = "always" // always enable colored output.
	Never  ColorMode = "never"  // disable colored output.
	Auto   ColorMode = "auto"   // automatically enable / disable colored output based on terminal settings.
)

type Colorer

type Colorer struct {
	Colors  []*color.Color
	Red     *color.Color
	Green   *color.Color
	Blue    *color.Color
	Cyan    *color.Color
	Magenta *color.Color
	Yellow  *color.Color
}

func NewColorer

func NewColorer(when ColorMode) *Colorer

func (*Colorer) ProcessInfo

func (c *Colorer) ProcessInfo(host string, process *tetragon.Process) (string, string)

type CompactEncoder

type CompactEncoder struct {
	Writer     io.Writer
	Colorer    *Colorer
	Timestamps bool
}

CompactEncoder encodes tetragon.GetEventsResponse in a short format with emojis and colors.

func NewCompactEncoder

func NewCompactEncoder(w io.Writer, colorMode ColorMode, timestamps bool) *CompactEncoder

NewCompactEncoder initializes and returns a pointer to CompactEncoder.

func (*CompactEncoder) Encode

func (p *CompactEncoder) Encode(v interface{}) error

Encode implements EventEncoder.Encode.

func (*CompactEncoder) EventToString

func (p *CompactEncoder) EventToString(response *tetragon.GetEventsResponse) (string, error)

type EventEncoder

type EventEncoder interface {
	Encode(v interface{}) error
}

EventEncoder is an interface for encoding tetragon.GetEventsResponse.

Jump to

Keyboard shortcuts

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