forked from snagles/docker-registry-manager
/
registry.go
28 lines (24 loc) · 957 Bytes
/
registry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package client
import (
"github.com/DemonVex/docker-registry-manager/utilities"
"github.com/Sirupsen/logrus"
)
// HealthCheck takes in a registry URL and checks for communication errors
//
// Create and execute basic GET request to test if each registry can be reached
// To determine registry status we test the base registry route of /v2/ and check
// the HTTP response code for a 200 response (200 is a successful request)
func HealthCheck(uri string) error {
// Create and execute a plain get request and check the http status code
response, err := get(uri)
if err != nil {
// Notify of error
utils.Log.WithFields(logrus.Fields{
"Registry URLs": uri,
"Error": err,
"HTTP Response": response,
"Possible Fix": "Check to see if your registry is up, and serving on the correct port with 'docker ps'.",
}).Error("Get request to registry timed out/failed! Is the URL correct, and is the registry active?")
}
return err
}