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"
)
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)