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 new method regexMatchGroup #1832

Open
suikast42 opened this issue Nov 7, 2023 · 0 comments
Open

Add new method regexMatchGroup #1832

suikast42 opened this issue Nov 7, 2023 · 0 comments

Comments

@suikast42
Copy link

For example. To extract traefik hostnames with consul-tepmplate a template like shown below could be very handy.

This template could be very helpful for dns resolution on some limited client networks for example.

{{ range services }}
  {{ range .Tags }}
    {{ $pattern := `traefik\.http\.routers\..+\.rule=Host\('([a-zA-Z0-9.-]+)'\)` }}
    {{ $matches := regexMatchGroup $pattern . }}
    {{ if $matches }}
      {{ $extractedDomain := index (index $matches 0) 1 }}
      Extracted Domain: {{ $extractedDomain }}
    {{ end }}
  {{ end }}
{{ end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants