hashicorp / hashicorp/consul-template
Add new method regexMatchGroup
- Dominant language
- Go
- Stars
- 4.8k
- Forks
- 801
- Avg merge
- 4h 5m
- Merged PRs (30d)
- 6
Description
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.
```hcl
{{ 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 }}
```
Contributor guide
Research direction
Start by locating the existing template-function registration and regex-related tests in consul-template. Use the HCL example in the issue to determine the expected capture-group result for regexMatchGroup, then add coverage showing the extracted hostname is available to the template. Done means the example renders the captured domain as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100