client: Use http.Client instead of a string for the socket

This converts the client and weldrcheck functions to use http.Client for
connections instead of passing around the socket path and opening it for
each test.
This commit is contained in:
Brian C. Lane 2020-03-06 18:22:37 -08:00 committed by Tom Gundersen
parent 2778efed6f
commit 46c3bed153
7 changed files with 73 additions and 57 deletions

View file

@ -3,9 +3,24 @@
package main
import (
"context"
"net"
"net/http"
"time"
"github.com/osbuild/osbuild-composer/internal/weldrcheck"
)
func main() {
weldrcheck.Run("/run/weldr/api.socket")
client := &http.Client{
// TODO This may be too short/simple for downloading images
Timeout: 60 * time.Second,
Transport: &http.Transport{
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial("unix", "/run/weldr/api.socket")
},
},
}
weldrcheck.Run(client)
}