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

[NET-9450] Add byPort function for grouping services by port number #1939

Merged
merged 1 commit into from
May 21, 2024

Conversation

nathancoleman
Copy link
Member

This PR adds a byPort function to consul-template.

Similar in nature to the existing byTag function, byPort will group services in a list by port number.

Example

Input

[
  {ID: "serviceA", Port: 8080},
  {ID: "serviceB", Port: 8080},
  {ID: "serviceC", Port: 9090}
]

should return

{
  8080: [
    {ID: "serviceA", Port: 8080},
    {ID: "serviceB", Port: 8080},
  ],
  9090: [
    {ID: "serviceC", Port: 9090}
  ]
}

HealthService, CatalogService and NomadService types are supported. Notably, CatalogSnippet (code) and NomadServicesSnippet (code) types are not supported since the responses from the corresponding API endpoints do not include port numbers for each service.

@nathancoleman nathancoleman marked this pull request as ready for review May 20, 2024 22:12
@nathancoleman
Copy link
Member Author

I will dig into the CI failures tomorrow. I believe they're widespread issues not specific to this PR since the added tests pass locally.

Copy link
Member

@blake blake left a comment

Choose a reason for hiding this comment

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

UX looks good to me.

Copy link
Member

@jm96441n jm96441n left a comment

Choose a reason for hiding this comment

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

LGTM!

@nathancoleman nathancoleman merged commit 4a5c7b0 into main May 21, 2024
54 checks passed
@nathancoleman nathancoleman deleted the by-port branch May 21, 2024 16:12
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.

3 participants