From 5d8045f5eee26b326d19db26ecb777380e0e6056 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 5 Nov 2014 16:57:24 +0000 Subject: [PATCH] Factor out error check --- nameserver/updater.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/nameserver/updater.go b/nameserver/updater.go index f528b193..a07c2c75 100644 --- a/nameserver/updater.go +++ b/nameserver/updater.go @@ -4,17 +4,19 @@ import ( "github.com/fsouza/go-dockerclient" ) -func StartUpdater(apiPath string, zone Zone) error { - client, err := docker.NewClient(apiPath) +func checkError(err error, apiPath string) { if err != nil { Error.Fatalf("Unable to connect to Docker API on %s: %s", apiPath, err) } +} + +func StartUpdater(apiPath string, zone Zone) error { + client, err := docker.NewClient(apiPath) + checkError(err, apiPath) events := make(chan *docker.APIEvents) err = client.AddEventListener(events) - if err != nil { - Error.Fatalf("Unable to connect to Docker API on %s: %s", apiPath, err) - } + checkError(err, apiPath) Info.Printf("Using Docker API on %s", apiPath)