mirror of
https://github.com/genuinetools/reg.git
synced 2024-05-10 00:38:31 -04:00
32589e90be
* passing context in layer calls * more contexting * clair folder and context in handlers * fixed token transport to reuse request context * tests * taking out context pass in server handlers
22 lines
431 B
Go
22 lines
431 B
Go
package registry
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
// Ping tries to contact a registry URL to make sure it is up and accessible.
|
|
func (r *Registry) Ping(ctx context.Context) error {
|
|
url := r.url("/v2/")
|
|
r.Logf("registry.ping url=%s", url)
|
|
req, err := http.NewRequest("GET", url, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
resp, err := r.Client.Do(req.WithContext(ctx))
|
|
if resp != nil {
|
|
defer resp.Body.Close()
|
|
}
|
|
return err
|
|
}
|