From 1b677b0ebd3e86cea30348521ffa7ad37b73c558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Matczuk?= Date: Tue, 26 Mar 2024 15:47:08 +0100 Subject: [PATCH] command/ready: support : syntax --- command/ready/ready.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/command/ready/ready.go b/command/ready/ready.go index 74c96c92..f385ac7b 100644 --- a/command/ready/ready.go +++ b/command/ready/ready.go @@ -8,6 +8,7 @@ package ready import ( "fmt" + "net" "net/http" "net/http/httputil" @@ -19,7 +20,15 @@ type command struct { } func (c *command) runE(cmd *cobra.Command, _ []string) error { - resp, err := http.Get("http://" + c.apiAddr + "/readyz") //nolint:noctx // net/http.Get must not be called + host, port, err := net.SplitHostPort(c.apiAddr) + if err != nil { + return err + } + if host == "" { + host = "localhost" + } + + resp, err := http.Get("http://" + net.JoinHostPort(host, port) + "/readyz") //nolint:noctx // net/http.Get must not be called if err != nil { return err }