From 244a2d75be6f34f59ae8fb05b147dfe0d35cb9ba Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 20 Jul 2023 00:33:26 +0200 Subject: [PATCH] feat(kumact): define User-Agent Defines the User-Agent value kumactl/1.0.0 (Linux; amd64; Kuma/a1f30b4) With * 1.0.0 , the version of Kuma, * Kuma the name of the Product * a1f30b4 the short git commit Signed-off-by: Matthieu MOREL --- app/kumactl/pkg/client/api_server_client.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/kumactl/pkg/client/api_server_client.go b/app/kumactl/pkg/client/api_server_client.go index ed4e0238a86d..eaa5f0e237d5 100644 --- a/app/kumactl/pkg/client/api_server_client.go +++ b/app/kumactl/pkg/client/api_server_client.go @@ -1,18 +1,28 @@ package client import ( + "fmt" "net/http" "net/url" + "runtime" "time" "github.com/pkg/errors" config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1" util_http "github.com/kumahq/kuma/pkg/util/http" + kuma_version "github.com/kumahq/kuma/pkg/version" ) func ApiServerClient(coordinates *config_proto.ControlPlaneCoordinates_ApiServer, timeout time.Duration) (util_http.Client, error) { - headers := make(map[string]string) + headers := map[string]string{ + "User-Agent": fmt.Sprintf("kumactl/%s (%s; %s; %s/%s)", + kuma_version.Build.Version, + runtime.GOOS, + runtime.GOARCH, + kuma_version.Build.Product, + kuma_version.Build.GitCommit[:7]), + } baseURL, err := url.Parse(coordinates.Url) if err != nil { return nil, errors.Wrapf(err, "Failed to parse API Server URL")