aboutsummaryrefslogtreecommitdiff
path: root/middleware/auto/regexp.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-10-17 18:37:56 +0100
committerGravatar GitHub <noreply@github.com> 2016-10-17 18:37:56 +0100
commitd536272201b117e18c909a921358fa19dee89f35 (patch)
tree35bf3d9a118401cb6e51d6bc20e1e7eb3b0b5f95 /middleware/auto/regexp.go
parent2eafe3ee94bc4b1e94000bc74f8ee524132ae27c (diff)
downloadcoredns-d536272201b117e18c909a921358fa19dee89f35.tar.gz
coredns-d536272201b117e18c909a921358fa19dee89f35.tar.zst
coredns-d536272201b117e18c909a921358fa19dee89f35.zip
middleware/auto: add (#333)
Add auto-load middleware that automatically picks up zones. Every X seconds it will scan for new zones. Add tests and documentation. Make 'make test' use -race.
Diffstat (limited to 'middleware/auto/regexp.go')
-rw-r--r--middleware/auto/regexp.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/middleware/auto/regexp.go b/middleware/auto/regexp.go
new file mode 100644
index 000000000..fa424ec7e
--- /dev/null
+++ b/middleware/auto/regexp.go
@@ -0,0 +1,20 @@
+package auto
+
+// rewriteToExpand rewrites our template string to one that we can give to regexp.ExpandString. This basically
+// involves prefixing any '{' with a '$'.
+func rewriteToExpand(s string) string {
+ // Pretty dumb at the moment, every { will get a $ prefixed.
+ // Also wasteful as we build the string with +=. This is OKish
+ // as we do this during config parsing.
+
+ copy := ""
+
+ for _, c := range s {
+ if c == '{' {
+ copy += "$"
+ }
+ copy += string(c)
+ }
+
+ return copy
+}