From eec1ba8b4f760b987eee36e5afbd30c650082cd5 Mon Sep 17 00:00:00 2001 From: Thomas Knickman Date: Thu, 2 Feb 2023 20:35:13 -0500 Subject: [PATCH] fix(cli): prefer constant over name (#3608) --- cli/internal/ci/ci.go | 5 +++++ cli/internal/client/client.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cli/internal/ci/ci.go b/cli/internal/ci/ci.go index bcc56f95ed2e37..a22ad78d2d5347 100644 --- a/cli/internal/ci/ci.go +++ b/cli/internal/ci/ci.go @@ -16,6 +16,11 @@ func Name() string { return Info().Name } +// Constant returns the name of the CI vendor as a constant +func Constant() string { + return Info().Constant +} + // Info returns information about a CI vendor func Info() Vendor { // check both the env var key and value diff --git a/cli/internal/client/client.go b/cli/internal/client/client.go index 534fc7684c5e5d..462ebbed2a0293 100644 --- a/cli/internal/client/client.go +++ b/cli/internal/client/client.go @@ -283,7 +283,7 @@ func (c *ApiClient) PutArtifact(hash string, artifactBody []byte, duration int, } req.Header.Set("User-Agent", c.UserAgent()) if ci.IsCi() { - req.Header.Set("x-artifact-client-ci", ci.Name()) + req.Header.Set("x-artifact-client-ci", ci.Constant()) } if tag != "" { req.Header.Set("x-artifact-tag", tag) @@ -403,7 +403,7 @@ func (c *ApiClient) RecordAnalyticsEvents(events []map[string]interface{}) error } req.Header.Set("User-Agent", c.UserAgent()) if ci.IsCi() { - req.Header.Set("x-artifact-client-ci", ci.Name()) + req.Header.Set("x-artifact-client-ci", ci.Constant()) } resp, err := c.HttpClient.Do(req) if resp != nil && resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {