summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-05-13 20:40:19 +0200
committerGitHub <noreply@github.com>2019-05-13 20:40:19 +0200
commitec382e4c8df06558cac73df26aee8e3a3f2429df (patch)
treebad4e7c7b63747220135087a3237d23e28951a25 /libpod
parent25415e0b0edb0f120cedcc10b9aed7f15cd9e086 (diff)
parentd1fc3fc702cce6efca4a20f972ef1931c8392548 (diff)
downloadpodman-ec382e4c8df06558cac73df26aee8e3a3f2429df.tar.gz
podman-ec382e4c8df06558cac73df26aee8e3a3f2429df.tar.bz2
podman-ec382e4c8df06558cac73df26aee8e3a3f2429df.zip
Merge pull request #3083 from openSUSE/systemd-optional
Add `systemd` build tag
Diffstat (limited to 'libpod')
-rw-r--r--libpod/events/events.go4
-rw-r--r--libpod/events/events_linux.go8
-rw-r--r--libpod/events/journal_linux.go7
-rw-r--r--libpod/events/journal_unsupported.go8
4 files changed, 24 insertions, 3 deletions
diff --git a/libpod/events/events.go b/libpod/events/events.go
index 650a47bfb..1ec79bcd7 100644
--- a/libpod/events/events.go
+++ b/libpod/events/events.go
@@ -10,6 +10,10 @@ import (
"github.com/pkg/errors"
)
+// ErrNoJournaldLogging indicates that there is no journald logging
+// supported (requires libsystemd)
+var ErrNoJournaldLogging = errors.New("No support for journald logging")
+
// String returns a string representation of EventerType
func (et EventerType) String() string {
if et == LogFile {
diff --git a/libpod/events/events_linux.go b/libpod/events/events_linux.go
index da5d7965e..11f309574 100644
--- a/libpod/events/events_linux.go
+++ b/libpod/events/events_linux.go
@@ -8,12 +8,14 @@ import (
)
// NewEventer creates an eventer based on the eventer type
-func NewEventer(options EventerOptions) (Eventer, error) {
- var eventer Eventer
+func NewEventer(options EventerOptions) (eventer Eventer, err error) {
logrus.Debugf("Initializing event backend %s", options.EventerType)
switch strings.ToUpper(options.EventerType) {
case strings.ToUpper(Journald.String()):
- eventer = EventJournalD{options}
+ eventer, err = newEventJournalD(options)
+ if err != nil {
+ return nil, errors.Wrapf(err, "eventer creation")
+ }
case strings.ToUpper(LogFile.String()):
eventer = EventLogFile{options}
default:
diff --git a/libpod/events/journal_linux.go b/libpod/events/journal_linux.go
index 8ba5bc2c7..264c84f89 100644
--- a/libpod/events/journal_linux.go
+++ b/libpod/events/journal_linux.go
@@ -1,3 +1,5 @@
+// +build systemd
+
package events
import (
@@ -15,6 +17,11 @@ type EventJournalD struct {
options EventerOptions
}
+// newEventJournalD creates a new journald Eventer
+func newEventJournalD(options EventerOptions) (Eventer, error) {
+ return EventJournalD{options}, nil
+}
+
// Write to journald
func (e EventJournalD) Write(ee Event) error {
m := make(map[string]string)
diff --git a/libpod/events/journal_unsupported.go b/libpod/events/journal_unsupported.go
new file mode 100644
index 000000000..c91d81f12
--- /dev/null
+++ b/libpod/events/journal_unsupported.go
@@ -0,0 +1,8 @@
+// +build !systemd
+
+package events
+
+// newEventJournalD always returns an error if libsystemd not found
+func newEventJournalD(options EventerOptions) (Eventer, error) {
+ return nil, ErrNoJournaldLogging
+}