From 0ec19040dccc9662f396be54ed428fdf9aa2c66f Mon Sep 17 00:00:00 2001 From: Jonah Back Date: Mon, 4 Dec 2023 08:31:59 -0800 Subject: [PATCH] chore: address review comments --- internal/adminapi/endpoints.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/adminapi/endpoints.go b/internal/adminapi/endpoints.go index 21eb548557..3d47f075cb 100644 --- a/internal/adminapi/endpoints.go +++ b/internal/adminapi/endpoints.go @@ -165,9 +165,9 @@ func adminAPIFromEndpoint( // Format for calling the Admin API. If the port explicitly indicates http as the AppProtocol, use http. // Otherwise, default to HTTPS as a best practice. Consumers may want to use HTTP if they have a service mesh in place which // is already handling TLS authentication for them. - format := "https://%s:%d" - if port.AppProtocol != nil && strings.Compare(*port.AppProtocol, "http") == 0 { - format = "http://%s:%d" + adminAPIAddressFormat := "https://%s:%d" + if port.AppProtocol != nil && *port.AppProtocol == "http" { + adminAPIAddressFormat = "http://%s:%d" } // NOTE: Endpoint's addresses are assumed to be fungible, therefore we pick @@ -188,7 +188,7 @@ func adminAPIFromEndpoint( address := fmt.Sprintf("%s.%s.%s.svc", ipAddr, service.Name, service.Namespace) return DiscoveredAdminAPI{ - Address: fmt.Sprintf(format, address, *port.Port), + Address: fmt.Sprintf(adminAPIAddressFormat, address, *port.Port), PodRef: podNN, }, nil @@ -197,7 +197,7 @@ func adminAPIFromEndpoint( address := fmt.Sprintf("%s.%s.pod", ipAddr, service.Namespace) return DiscoveredAdminAPI{ - Address: fmt.Sprintf(format, address, *port.Port), + Address: fmt.Sprintf(adminAPIAddressFormat, address, *port.Port), PodRef: podNN, }, nil @@ -207,7 +207,7 @@ func adminAPIFromEndpoint( bounded = fmt.Sprintf("[%s]", bounded) } return DiscoveredAdminAPI{ - Address: fmt.Sprintf(format, bounded, *port.Port), + Address: fmt.Sprintf(adminAPIAddressFormat, bounded, *port.Port), PodRef: podNN, }, nil