Skip to content

feat(clients): allow custom http headers #1906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

d0weinberger
Copy link
Contributor

@d0weinberger d0weinberger commented May 23, 2025

Why this PR?

Allowing users to set additional HTTP headers for requests.

What has changed?

The multiline environment variable MONACO_ADDITIONAL_HTTP_HEADERS is introduced. Its content is parsed. Each line represents an HTTP header. The key- and value part of the header are separated via :. These HTTP headers are appended to all requests sent via Monaco.

How does it do it?

The variable is retrieved and parsed at all places where the client factory is used to create REST clients. It is also parsed once at the start of Monaco to log the header keys, if any are present.

How is it tested?

To be done.
Currently, only parsing the environment variable contents is tested. Passing it to the clients is not tested yet.

How does it affect users?

Allowing users to set additional HTTP headers for requests via the environment variable MONACO_ADDITIONAL_HTTP_HEADERS.

@d0weinberger d0weinberger changed the title Feat/allow custom http headers feat(clients): allow custom http headers May 23, 2025
@d0weinberger d0weinberger force-pushed the feat/allow-custom-http-headers branch from 7f0de93 to 6f18853 Compare May 23, 2025 10:55
@d0weinberger d0weinberger force-pushed the feat/allow-custom-http-headers branch 3 times, most recently from c8217bb to 874a4a3 Compare June 3, 2025 08:11
@d0weinberger d0weinberger marked this pull request as ready for review June 3, 2025 08:11
@d0weinberger d0weinberger requested a review from a team as a code owner June 3, 2025 08:11
@d0weinberger d0weinberger force-pushed the feat/allow-custom-http-headers branch 3 times, most recently from 64514cf to 712fd67 Compare June 4, 2025 14:27
@Laubi Laubi requested a review from Kirdock June 5, 2025 07:56
@d0weinberger d0weinberger force-pushed the feat/allow-custom-http-headers branch 2 times, most recently from b8cd2cb to 7c00e10 Compare June 5, 2025 14:12
Kirdock
Kirdock previously approved these changes Jun 5, 2025
arthurpitman
arthurpitman previously approved these changes Jun 6, 2025
The environment variable `MONACO_ADDITIONAL_HTTP_HEADERS` is defined and the logic for parsing a http header map from the env var content is defined and tested.
This commit adds a dependency to the specific core lib commit which contains the feature of settings additional custom http headers.

# Conflicts:
#	go.mod
#	go.sum
The additional http headers set via `MONACO_ADDITIONAL_HTTP_HEADERS` are parsed and used in all places where a client factory is used to create REST clients. Additionally, it is parsed once in the runner in order to log the keys of the additional HTTP headers right at the start of Monaco.
@d0weinberger d0weinberger dismissed stale reviews from arthurpitman and Kirdock via 29b8637 June 6, 2025 10:43
@d0weinberger d0weinberger force-pushed the feat/allow-custom-http-headers branch from 7c00e10 to 29b8637 Compare June 6, 2025 10:43
Copy link

sonarqubecloud bot commented Jun 6, 2025

@arthurpitman arthurpitman self-requested a review June 6, 2025 11:46
@arthurpitman arthurpitman added the run-e2e-test Manually trigger the E2E tests for reviewed PRs label Jun 6, 2025
Copy link

github-actions bot commented Jun 6, 2025

E2E Test Results

    3 files   -   1    152 suites   - 128   25m 31s ⏱️ - 27m 1s
2 188 tests +  2  2 186 ✅ +  3  2 💤 ±0  0 ❌  - 1 
2 188 runs   - 229  2 186 ✅  - 228  2 💤 ±0  0 ❌  - 1 

Results for commit 29b8637. ± Comparison against base commit d6638c7.

This pull request removes 2 and adds 4 tests. Note that renamed tests count towards both.
github.com/dynatrace/dynatrace-configuration-as-code/v2/test/configuration/pagination ‑ TestPaginationClassic
github.com/dynatrace/dynatrace-configuration-as-code/v2/test/configuration/pagination ‑ TestPaginationPlatform
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/environment ‑ TestWithCustomHeadersSetReturnsExpectedMap
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/environment ‑ TestWithCustomHeadersSetReturnsExpectedMap/when_env_var_is_not_set,_parsed_map_is_as_expected
github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/environment ‑ TestWithCustomHeadersSetReturnsExpectedMap/when_env_var_is_set,_parsed_map_is_as_expected
github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/client ‑ TestCreateClientSetWithAdditionalHeaders

♻️ This comment has been updated with latest results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-e2e-test Manually trigger the E2E tests for reviewed PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants