github.com/AbhinandanKurakure/podman/v3@v3.4.10/libpod/events/config.go (about) 1 package events 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/pkg/errors" 8 ) 9 10 // EventerType ... 11 type EventerType int 12 13 const ( 14 // LogFile indicates the event logger will be a logfile 15 LogFile EventerType = iota 16 // Journald indicates journald should be used to log events 17 Journald EventerType = iota 18 // Null is a no-op events logger. It does not read or write events. 19 Null EventerType = iota 20 ) 21 22 // Event describes the attributes of a libpod event 23 type Event struct { 24 // ContainerExitCode is for storing the exit code of a container which can 25 // be used for "internal" event notification 26 ContainerExitCode int `json:",omitempty"` 27 // ID can be for the container, image, volume, etc 28 ID string `json:",omitempty"` 29 // Image used where applicable 30 Image string `json:",omitempty"` 31 // Name where applicable 32 Name string `json:",omitempty"` 33 // Network is the network name in a network event 34 Network string `json:"network,omitempty"` 35 // Status describes the event that occurred 36 Status Status 37 // Time the event occurred 38 Time time.Time 39 // Type of event that occurred 40 Type Type 41 42 Details 43 } 44 45 // Details describes specifics about certain events, specifically around 46 // container events 47 type Details struct { 48 // ID is the event ID 49 ID string 50 // Attributes can be used to describe specifics about the event 51 // in the case of a container event, labels for example 52 Attributes map[string]string 53 } 54 55 // EventerOptions describe options that need to be passed to create 56 // an eventer 57 type EventerOptions struct { 58 // EventerType describes whether to use journald or a file 59 EventerType string 60 // LogFilePath is the path to where the log file should reside if using 61 // the file logger 62 LogFilePath string 63 } 64 65 // Eventer is the interface for journald or file event logging 66 type Eventer interface { 67 // Write an event to a backend 68 Write(event Event) error 69 // Read an event from the backend 70 Read(ctx context.Context, options ReadOptions) error 71 // String returns the type of event logger 72 String() string 73 } 74 75 // ReadOptions describe the attributes needed to read event logs 76 type ReadOptions struct { 77 // EventChannel is the comm path back to user 78 EventChannel chan *Event 79 // Filters are key/value pairs that describe to limit output 80 Filters []string 81 // FromStart means you start reading from the start of the logs 82 FromStart bool 83 // Since reads "since" the given time 84 Since string 85 // Stream is follow 86 Stream bool 87 // Until reads "until" the given time 88 Until string 89 } 90 91 // Type of event that occurred (container, volume, image, pod, etc) 92 type Type string 93 94 // Status describes the actual event action (stop, start, create, kill) 95 type Status string 96 97 const ( 98 // Container - event is related to containers 99 Container Type = "container" 100 // Image - event is related to images 101 Image Type = "image" 102 // Network - event is related to networks 103 Network Type = "network" 104 // Pod - event is related to pods 105 Pod Type = "pod" 106 // System - event is related to Podman whole and not to any specific 107 // container/pod/image/volume 108 System Type = "system" 109 // Volume - event is related to volumes 110 Volume Type = "volume" 111 112 // Attach ... 113 Attach Status = "attach" 114 // AutoUpdate ... 115 AutoUpdate Status = "auto-update" 116 // Build ... 117 Build Status = "build" 118 // Checkpoint ... 119 Checkpoint Status = "checkpoint" 120 // Cleanup ... 121 Cleanup Status = "cleanup" 122 // Commit ... 123 Commit Status = "commit" 124 // Copy ... 125 Copy Status = "copy" 126 // Create ... 127 Create Status = "create" 128 // Exec ... 129 Exec Status = "exec" 130 // ExecDied indicates that an exec session in a container died. 131 ExecDied Status = "exec_died" 132 // Exited indicates that a container's process died 133 Exited Status = "died" 134 // Export ... 135 Export Status = "export" 136 // History ... 137 History Status = "history" 138 // Import ... 139 Import Status = "import" 140 // Init ... 141 Init Status = "init" 142 // Kill ... 143 Kill Status = "kill" 144 // LoadFromArchive ... 145 LoadFromArchive Status = "loadfromarchive" 146 // Mount ... 147 Mount Status = "mount" 148 // NetworkConnect 149 NetworkConnect Status = "connect" 150 // NetworkDisconnect 151 NetworkDisconnect Status = "disconnect" 152 // Pause ... 153 Pause Status = "pause" 154 // Prune ... 155 Prune Status = "prune" 156 // Pull ... 157 Pull Status = "pull" 158 // Push ... 159 Push Status = "push" 160 // Refresh indicates that the system refreshed the state after a 161 // reboot. 162 Refresh Status = "refresh" 163 // Remove ... 164 Remove Status = "remove" 165 // Renumber indicates that lock numbers were reallocated at user 166 // request. 167 Renumber Status = "renumber" 168 // Restart indicates the target was restarted via an API call. 169 Restart Status = "restart" 170 // Restore ... 171 Restore Status = "restore" 172 // Save ... 173 Save Status = "save" 174 // Start ... 175 Start Status = "start" 176 // Stop ... 177 Stop Status = "stop" 178 // Sync ... 179 Sync Status = "sync" 180 // Tag ... 181 Tag Status = "tag" 182 // Unmount ... 183 Unmount Status = "unmount" 184 // Unpause ... 185 Unpause Status = "unpause" 186 // Untag ... 187 Untag Status = "untag" 188 ) 189 190 // EventFilter for filtering events 191 type EventFilter func(*Event) bool 192 193 var ( 194 // ErrEventTypeBlank indicates the event log found something done by podman 195 // but it isn't likely an event 196 ErrEventTypeBlank = errors.New("event type blank") 197 198 // ErrEventNotFound indicates that the event was not found in the event log 199 ErrEventNotFound = errors.New("unable to find event") 200 )