Factor out error check

This commit is contained in:
Bryan Boreham committed 2014-11-05 16:57:24 +00:00
1 parent a0a5921148
commit 5d8045f5ee
1 file changed
+7 -5
+7 -5
View File
@@ -4,17 +4,19 @@ import (
"github.com/fsouza/go-dockerclient" "github.com/fsouza/go-dockerclient"
) )
func StartUpdater(apiPath string, zone Zone) error { func checkError(err error, apiPath string) {
client, err := docker.NewClient(apiPath)
if err != nil { if err != nil {
Error.Fatalf("Unable to connect to Docker API on %s: %s", apiPath, err) 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) events := make(chan *docker.APIEvents)
err = client.AddEventListener(events) err = client.AddEventListener(events)
if err != nil { checkError(err, apiPath)
Error.Fatalf("Unable to connect to Docker API on %s: %s", apiPath, err)
}
Info.Printf("Using Docker API on %s", apiPath) Info.Printf("Using Docker API on %s", apiPath)