Skip to content
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

feat(reloader): allow passing http Header in the http reloader request #8042

Conversation

RouxAntoine
Copy link

@RouxAntoine RouxAntoine commented Jan 6, 2025

This could be usefull in case of secured remote API by passing Authorization header usecase here in prometheus config map reloader
https://github.com/prometheus-operator/prometheus-operator/blob/release-0.73/cmd/prometheus-config-reloader/main.go#L170 when we call prometheus backend which could be password protected

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

adding Header list in HttpReloader struct.
adding optional ReloadHeader option in reloader.Options parameter of New constructor.

Verification

Adding an unit test which check if Authorization header exists in the request issued by reloader.

@RouxAntoine RouxAntoine force-pushed the feature/allow-passing-header-in-reloader branch from 1bae47a to e837f2a Compare January 6, 2025 16:29
This could be usefull in case of secured remote API by passing Authorization header
usecase here in prometheus config map reloader
https://github.com/prometheus-operator/prometheus-operator/blob/release-0.73/cmd/prometheus-config-reloader/main.go#L170
when we call prometheus backend which could be password protected

Signed-off-by: RouxAntoine <[email protected]>
@simonpasquier
Copy link
Contributor

i don't think that it's necessary since the reloader can already take an http.Client option.

@RouxAntoine
Copy link
Author

RouxAntoine commented Jan 7, 2025

i don't think that it's necessary since the reloader can already take an http.Client option.

Hello, thanks for reply, I though too, but don't find anything that allow to define request header in the http.Client, do you have some pointer how to do that please ?

https://pkg.go.dev/net/http#Client

@simonpasquier
Copy link
Contributor

you can use https://pkg.go.dev/k8s.io/client-go/transport#NewBasicAuthRoundTripper to override the default Transport.

@RouxAntoine
Copy link
Author

you can use https://pkg.go.dev/k8s.io/client-go/transport#NewBasicAuthRoundTripper to override the default Transport.

nice thanks, I will and close this 🙂

@RouxAntoine RouxAntoine closed this Jan 7, 2025
@RouxAntoine RouxAntoine deleted the feature/allow-passing-header-in-reloader branch January 7, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants