-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[BUGFIX] Added Service Meta support in configuration files #4047
[BUGFIX] Added Service Meta support in configuration files #4047
Conversation
Fixes hashicorp#4045 Was not added by mistake in hashicorp#3881
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.
Thanks for the PR!
Can you also add documentation for this? Additionally, there may be appropriate place on the services page for a sub-section (eg "Service and Tag Names with DNS") talking about use cases or examples for service metadata.
We also missed updating a couple of spots in the @pierresouchay do you want to add that in this PR or separately? |
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 looks great to me - there is one nitpicky change that we should fix up but I think it's good after that.
agent/config/config.go
Outdated
@@ -319,6 +319,7 @@ type ServiceDefinition struct { | |||
Name *string `json:"name,omitempty" hcl:"name" mapstructure:"name"` | |||
Tags []string `json:"tags,omitempty" hcl:"tags" mapstructure:"tags"` | |||
Address *string `json:"address,omitempty" hcl:"address" mapstructure:"address"` | |||
Meta map[string]string `json:"node_meta,omitempty" hcl:"meta" mapstructure:"meta"` |
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.
JSON tag node_meta
seems like copy paste error here? should just be meta
like the others.
Also interesting that this wasn't caught by a test case - on the surface it seems like your tests would exercise that but in fact even when config looks like JSON we parse it into an interface{}
and then use mapstructure
. So the JSON tags here may never actually be used in Consul, and I don't think we explicitly test native JSON parsing, but let's fix this so it doesn't bite someone one day!
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.
@banks Yes, Added missing Tests case in next patch in agent/config/runtime_test.go for HCL/JSON parsing
Add support for Meta in Consul's configuration, since #3881 only added support for Meta using HTTP registration of services.
Fixes #4045