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

Add tag annotation to Connect service registration #115

Merged
merged 2 commits into from
Jul 9, 2019
Merged

Conversation

adilyse
Copy link
Contributor

@adilyse adilyse commented Jul 8, 2019

Allows users to add Consul tags to their services via a Kubernetes
annotation.

Allows users to add Consul tags to their services via a Kubernetes
annotation.

// annotationTags is a list of tags to register with the service
// this is specified as a comma separated list e.g. abc,123
annotationTags = "consul.hashicorp.com/connect-service-tags"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it specific to connect? Why not service-tags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is specific for Connect, since it's only part of the connect injector.

tags := strings.Split(raw, ",")

// Create json array from the annotations
jsonTags, _ := json.Marshal(tags)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a JSON array but then it's being templated into HCL. Are there any json marshaling vs. HCL issues we might run into here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you should swallow the error here. Would be useful to surface instead I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a log message for this, but I don't think a bad annotation should stop connect injection. This will at least make it possible for folks to see what's happening if it's not what they expect in this situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the hcl readme: "Arrays can be made by wrapping it in []. Example: ["foo", "bar", 42]", so we should be good for formatting.

@adilyse adilyse closed this Jul 8, 2019
@adilyse adilyse reopened this Jul 8, 2019
@adilyse adilyse closed this Jul 8, 2019
@adilyse adilyse reopened this Jul 8, 2019
@adilyse adilyse merged commit bccf2e2 into master Jul 9, 2019
@adilyse adilyse deleted the add-tags branch July 9, 2019 00:01
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.

None yet

2 participants