From ea7be214aee6c071a6412ce21d0c8f2b8cacc4a8 Mon Sep 17 00:00:00 2001 From: Kent Quirk Date: Mon, 4 Nov 2024 18:06:07 -0500 Subject: [PATCH] Add a way to specify the team key for config fetches --- config/configLoadHelpers.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/config/configLoadHelpers.go b/config/configLoadHelpers.go index bc662dda77..7c0316555d 100644 --- a/config/configLoadHelpers.go +++ b/config/configLoadHelpers.go @@ -74,7 +74,25 @@ func getReaderFor(u string) (io.ReadCloser, Format, error) { } return r, formatFromFilename(uu.Path), nil case "http", "https": - resp, err := http.Get(u) + // We need to make an HTTP request but we might need to add the + // x-honeycomb-team header which we get from the environment; we use the + // same header for all requests. This isn't particularly flexible, but + // we think that it's good enough for the experimental stage of this + // feature. + req, err := http.NewRequest("GET", u, nil) + if err != nil { + return nil, FormatUnknown, err + } + + // We use a different envvar for the team key because it's not the same + // key used for ingestion. This is not currently documented because it's + // experimental and we might change it later. + key := os.Getenv("HONEYCOMB_CONFIG_KEY") + if key != "" { + req.Header.Set("X-Honeycomb-Team", key) + } + + resp, err := http.DefaultClient.Do(req) if err != nil { return nil, FormatUnknown, err }