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:
parent
2778efed6f
commit
46c3bed153
7 changed files with 73 additions and 57 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue