Improve error handling in adapter.go

This commit is contained in:
Matthias Loibl 2018-12-03 17:18:53 +01:00
parent 5d837a29dd
commit bef034e699
No known key found for this signature in database
GPG key ID: B1C7DF661ABB2C1A

View file

@ -22,7 +22,6 @@ import (
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
@ -200,7 +199,9 @@ func main() {
cmd.Name = "prometheus-metrics-adapter"
cmd.addFlags()
cmd.Flags().AddGoFlagSet(flag.CommandLine) // make sure we get the glog flags
cmd.Flags().Parse(os.Args)
if err := cmd.Flags().Parse(os.Args); err != nil {
glog.Fatalf("unable to parse flags: %v", err)
}
// make the prometheus client
promClient, err := cmd.makePromClient()
@ -280,7 +281,7 @@ func makePrometheusCAClient(caFilename string) (*http.Client, error) {
return nil, fmt.Errorf("failed to read prometheus-ca-file: %v", err)
}
if !pool.AppendCertsFromPEM(data) {
log.Printf("warning: no certs found in prometheus-ca-file")
return nil, fmt.Errorf("no certs found in prometheus-ca-file")
}
return &http.Client{