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

Set User object in alertmanager url. #1279

Merged
merged 1 commit into from
Mar 13, 2018

Conversation

limscoder
Copy link
Contributor

@limscoder limscoder commented Mar 8, 2018

Sets User object in alertmanager url to enable amtool to work with basic auth for use with proxies. Fixes #1028.

@stuartnelson3
Copy link
Contributor

thanks for the contribution! looking at this code, it seems to me that we just want to copy the amURL we're getting from the config, and then update the path. Can you check to see if this code works for you?

diff --git a/cli/utils.go b/cli/utils.go
index 256c677..0828373 100644
--- a/cli/utils.go
+++ b/cli/utils.go
@@ -27,11 +27,9 @@ func (s ByAlphabetical) Less(i, j int) bool {
 }
 
 func GetAlertmanagerURL(p string) url.URL {
-	return url.URL{
-		Scheme: (*alertmanagerUrl).Scheme,
-		Host:   (*alertmanagerUrl).Host,
-		Path:   path.Join((*alertmanagerUrl).Path, p),
-	}
+	amURL := **alertmanagerUrl
+	amURL.Path = path.Join((*alertmanagerUrl).Path, p)
+	return amURL
 }
 
 // Parse a list of labels (cli arguments)

@limscoder
Copy link
Contributor Author

@stuartnelson3 I'm not familiar with the ** operator. Does that copy a struct?

@limscoder limscoder closed this Mar 12, 2018
@limscoder limscoder reopened this Mar 12, 2018
@stuartnelson3
Copy link
Contributor

alertmanagerUrl is a reference to a reference (**url.URL), so the double ** de-references to the actual struct and makes a copy. Check out the playground:
https://play.golang.org/p/MjVJheu_7vQ

@limscoder
Copy link
Contributor Author

@stuartnelson3 that code works for me, and makes sense to copy the whole thing instead of selected properties. I updated the PR.

@stuartnelson3
Copy link
Contributor

cool. the code worked for me in my tests, can you double check that it works for you with your basic auth setup?

@limscoder
Copy link
Contributor Author

Yes, it works for me with basic auth

@stuartnelson3 stuartnelson3 merged commit d63c25a into prometheus:master Mar 13, 2018
hh pushed a commit to ii/alertmanager that referenced this pull request May 31, 2019
* Add --collector.netdev.device-whitelist flag

Sometimes it is desired to monitor only one netdev. The golang regexp
does not support a negated regex, so the ignored-devices flag is too
cumbersome for this task.
This change introduces a new flag: accept-devices, which is mutually
exclusive to ignored-devices. This flag allows specifying ONLY the
netdev you'd like.

Signed-off-by: Noam Meltzer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants