-
Notifications
You must be signed in to change notification settings - Fork 323
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-Agent header on Consul API calls #434
Conversation
516256f
to
529e291
Compare
* Upgrade to latest consul api package * Create common consul package that implements NewClient(). This function returns a Consul client that will set the header "Consul-K8s-Version" to the current consul-k8s version on all calls to Consul. * Swap to using this new constructor everywhere. * Add a linter that ensures we use our NewClient() function everywhere in the future.
529e291
to
dbaf1fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great stuff, and I like the linter too!
Tested it out and looks good.
I left one comment which isn't a blocker but I'd like to get other opinions on whether or not we should keep using DefaultConfig()
from API or duplicate it inside the new lib from a code readability standpoint.
So cool
consul-k8s % go run hack/lint-api-new-client/main.go
Found code using github.com/hashicorp/consul/api.NewClient()
instead of github.com/hashicorp/consul-k8s/consul.NewClient()
in the following files:
- github.com/hashicorp/consul-k8s/connect-inject/health_check_resource.go
exit status 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!!
Release 0.20.0
function returns a Consul client that will set the header
User-Agent: consul-k8s/<version>
on all calls to Consul.in the future. Cribbed from https://github.com/hashicorp/lint-consul-retry.
How I've tested this PR:
unit test
ran a request printer:
docker run -p 8501:8443 --rm -t mendhak/http-https-echo:17
then ran
CONSUL_HTTP_SSL_VERIFY=false consul-k8s get-consul-client-ca -output-file /tmp/out -server-addr localhost -server-port 8501
How I expect reviewers to test this PR:
Checklist: