mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-23 06:40:23 +00:00
32839948ef
The internal/ directory in Go has a special meaning, and indicates that those packages are not meant for external consumption. Ceph-CSI does provide public APIs for other projects to consume. There is no plan to keep the API of the internally used packages stable. Closes: #903 Signed-off-by: Niels de Vos <ndevos@redhat.com>
28 lines
537 B
Go
28 lines
537 B
Go
package util
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
"net/url"
|
|
"strconv"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
"k8s.io/klog"
|
|
)
|
|
|
|
// ValidateURL validates the url
|
|
func ValidateURL(c *Config) error {
|
|
_, err := url.Parse(c.MetricsPath)
|
|
return err
|
|
}
|
|
|
|
// StartMetricsServer starts http server
|
|
func StartMetricsServer(c *Config) {
|
|
addr := net.JoinHostPort(c.MetricsIP, strconv.Itoa(c.MetricsPort))
|
|
http.Handle(c.MetricsPath, promhttp.Handler())
|
|
err := http.ListenAndServe(addr, nil)
|
|
if err != nil {
|
|
klog.Fatalln(err)
|
|
}
|
|
}
|