aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-07-17 15:17:26 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-07-31 17:28:42 -0400
commitcdd5639d564624a6fbca426421d47c840dac8556 (patch)
treef3d803155a430f22150d5cf04ebfe3683cfe846a /libpod
parentfd73075cbe91a4b38fe835b1f17bbabe0971bad9 (diff)
downloadpodman-cdd5639d564624a6fbca426421d47c840dac8556.tar.gz
podman-cdd5639d564624a6fbca426421d47c840dac8556.tar.bz2
podman-cdd5639d564624a6fbca426421d47c840dac8556.zip
Expose Null eventer and allow its use in the Podman CLI
We need this specifically for tests, but others may find it useful if they don't explicitly need events and don't want the performance implications of using them. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/events/config.go2
-rw-r--r--libpod/events/events.go13
-rw-r--r--libpod/events/events_linux.go4
3 files changed, 15 insertions, 4 deletions
diff --git a/libpod/events/config.go b/libpod/events/config.go
index b9f01f3a5..96172d47b 100644
--- a/libpod/events/config.go
+++ b/libpod/events/config.go
@@ -14,6 +14,8 @@ const (
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
)
// Event describes the attributes of a libpod event
diff --git a/libpod/events/events.go b/libpod/events/events.go
index a898171c1..a80e97e90 100644
--- a/libpod/events/events.go
+++ b/libpod/events/events.go
@@ -16,11 +16,16 @@ var ErrNoJournaldLogging = errors.New("No support for journald logging")
// String returns a string representation of EventerType
func (et EventerType) String() string {
- if et == LogFile {
+ switch et {
+ case LogFile:
return "file"
-
+ case Journald:
+ return "journald"
+ case Null:
+ return "null"
+ default:
+ return "invalid"
}
- return "journald"
}
// IsValidEventer checks if the given string is a valid eventer type.
@@ -30,6 +35,8 @@ func IsValidEventer(eventer string) bool {
return true
case Journald.String():
return true
+ case Null.String():
+ return true
default:
return false
}
diff --git a/libpod/events/events_linux.go b/libpod/events/events_linux.go
index 11f309574..ffb100be8 100644
--- a/libpod/events/events_linux.go
+++ b/libpod/events/events_linux.go
@@ -18,8 +18,10 @@ func NewEventer(options EventerOptions) (eventer Eventer, err error) {
}
case strings.ToUpper(LogFile.String()):
eventer = EventLogFile{options}
+ case strings.ToUpper(Null.String()):
+ eventer = NewNullEventer()
default:
- return eventer, errors.Errorf("unknown event logger type: %s", strings.ToUpper(options.EventerType))
+ return nil, errors.Errorf("unknown event logger type: %s", strings.ToUpper(options.EventerType))
}
return eventer, nil
}