events

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Index

Constants

View Source
const (

	// Container - event is related to containers
	Container Type = "container"
	// Image - event is related to images
	Image Type = "image"
	// Pod - event is related to pods
	Pod Type = "pod"
	// System - event is related to Podman whole and not to any specific
	// container/pod/image/volume
	System Type = "system"
	// Volume - event is related to volumes
	Volume Type = "volume"

	// Attach ...
	Attach Status = "attach"
	// AutoUpdate ...
	AutoUpdate Status = "auto-update"
	// Checkpoint ...
	Checkpoint Status = "checkpoint"
	// Cleanup ...
	Cleanup Status = "cleanup"
	// Commit ...
	Commit Status = "commit"
	// Create ...
	Create Status = "create"
	// Exec ...
	Exec Status = "exec"
	// Exited indicates that a container's process died
	Exited Status = "died"
	// Export ...
	Export Status = "export"
	// History ...
	History Status = "history"
	// Import ...
	Import Status = "import"
	// Init ...
	Init Status = "init"
	// Kill ...
	Kill Status = "kill"
	// LoadFromArchive ...
	LoadFromArchive Status = "loadfromarchive"
	// Mount ...
	Mount Status = "mount"
	// Pause ...
	Pause Status = "pause"
	// Prune ...
	Prune Status = "prune"
	// Pull ...
	Pull Status = "pull"
	// Push ...
	Push Status = "push"
	// Refresh indicates that the system refreshed the state after a
	// reboot.
	Refresh Status = "refresh"
	// Remove ...
	Remove Status = "remove"
	// Renumber indicates that lock numbers were reallocated at user
	// request.
	Renumber Status = "renumber"
	// Restart indicates the target was restarted via an API call.
	Restart Status = "restart"
	// Restore ...
	Restore Status = "restore"
	// Save ...
	Save Status = "save"
	// Start ...
	Start Status = "start"
	// Stop ...
	Stop Status = "stop"
	// Sync ...
	Sync Status = "sync"
	// Tag ...
	Tag Status = "tag"
	// Unmount ...
	Unmount Status = "unmount"
	// Unpause ...
	Unpause Status = "unpause"
	// Untag ...
	Untag Status = "untag"
)
View Source
const DefaultEventerType = LogFile

DefaultEventerType is logfile when systemd is not present

Variables

View Source
var (
	// ErrEventTypeBlank indicates the event log found something done by podman
	// but it isn't likely an event
	ErrEventTypeBlank = errors.New("event type blank")

	// ErrEventNotFound indicates that the event was not found in the event log
	ErrEventNotFound = errors.New("unable to find event")
)
View Source
var ErrNoJournaldLogging = errors.New("No support for journald logging")

ErrNoJournaldLogging indicates that there is no journald logging supported (requires libsystemd)

Functions

func IsValidEventer added in v1.5.0

func IsValidEventer(eventer string) bool

IsValidEventer checks if the given string is a valid eventer type.

Types

type Event

type Event struct {
	// ContainerExitCode is for storing the exit code of a container which can
	// be used for "internal" event notification
	ContainerExitCode int `json:",omitempty"`
	// ID can be for the container, image, volume, etc
	ID string `json:",omitempty"`
	// Image used where applicable
	Image string `json:",omitempty"`
	// Name where applicable
	Name string `json:",omitempty"`
	// Status describes the event that occurred
	Status Status
	// Time the event occurred
	Time time.Time
	// Type of event that occurred
	Type Type
}

Event describes the attributes of a libpod event

func NewEvent

func NewEvent(status Status) Event

NewEvent creates a event struct and populates with the given status and time.

func (*Event) Recycle

func (e *Event) Recycle(path string, remove bool) error

Recycle checks if the event log has reach a limit and if so renames the current log and starts a new one. The remove bool indicates the old log file should be deleted.

func (*Event) ToHumanReadable

func (e *Event) ToHumanReadable() string

ToHumanReadable returns human readable event as a formatted string

func (*Event) ToJSONString

func (e *Event) ToJSONString() (string, error)

ToJSONString returns the event as a json'ified string

type EventFilter

type EventFilter func(*Event) bool

EventFilter for filtering events

type EventLogFile added in v1.3.0

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

EventLogFile is the structure for event writing to a logfile. It contains the eventer options and the event itself. Methods for reading and writing are also defined from it.

func (EventLogFile) Read added in v1.3.0

func (e EventLogFile) Read(options ReadOptions) error

Reads from the log file

func (EventLogFile) String added in v1.5.0

func (e EventLogFile) String() string

String returns a string representation of the logger

func (EventLogFile) Write added in v1.3.0

func (e EventLogFile) Write(ee Event) error

Writes to the log file

type EventToNull added in v1.3.0

type EventToNull struct{}

EventToNull is an eventer type that only performs write operations and only writes to /dev/null. It is meant for unittests only

func (EventToNull) Read added in v1.3.0

func (e EventToNull) Read(options ReadOptions) error

Read does nothing. Do not use it.

func (EventToNull) String added in v1.5.0

func (e EventToNull) String() string

String returns a string representation of the logger

func (EventToNull) Write added in v1.3.0

func (e EventToNull) Write(ee Event) error

Write eats the event and always returns nil

type Eventer added in v1.3.0

type Eventer interface {
	// Write an event to a backend
	Write(event Event) error
	// Read an event from the backend
	Read(options ReadOptions) error
	// String returns the type of event logger
	String() string
}

Eventer is the interface for journald or file event logging

func NewEventer added in v1.3.0

func NewEventer(options EventerOptions) (eventer Eventer, err error)

NewEventer creates an eventer based on the eventer type

func NewNullEventer added in v1.3.0

func NewNullEventer() Eventer

NewNullEventer returns a new null eventer. You should only do this for the purposes on internal libpod testing.

type EventerOptions added in v1.3.0

type EventerOptions struct {
	// EventerType describes whether to use journald or a file
	EventerType string
	// LogFilePath is the path to where the log file should reside if using
	// the file logger
	LogFilePath string
}

EventerOptions describe options that need to be passed to create an eventer

type EventerType added in v1.3.0

type EventerType int

EventerType ...

const (
	// LogFile indicates the event logger will be a logfile
	LogFile EventerType = iota
	// Journald indicates journald should be used to log events
	Journald EventerType = iota
	// Null is a no-op events logger. It does not read or write events.
	Null EventerType = iota
)

func (EventerType) String added in v1.3.0

func (et EventerType) String() string

String returns a string representation of EventerType

type ReadOptions added in v1.3.0

type ReadOptions struct {
	// EventChannel is the comm path back to user
	EventChannel chan *Event
	// Filters are key/value pairs that describe to limit output
	Filters []string
	// FromStart means you start reading from the start of the logs
	FromStart bool
	// Since reads "since" the given time
	Since string
	// Stream is follow
	Stream bool
	// Until reads "until" the given time
	Until string
}

ReadOptions describe the attributes needed to read event logs

type Status

type Status string

Status describes the actual event action (stop, start, create, kill)

func StringToStatus

func StringToStatus(name string) (Status, error)

StringToStatus converts a string to an Event Status TODO if we add more events, we might consider a go-generator to create the switch statement

func (Status) String

func (s Status) String() string

ToString converts a status to a string

type Type

type Type string

Type of event that occurred (container, volume, image, pod, etc)

func StringToType

func StringToType(name string) (Type, error)

StringToType converts string to an EventType

func (Type) String

func (t Type) String() string

ToString converts a Type to a string

Jump to

Keyboard shortcuts

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