Created
February 21, 2018 18:46
-
-
Save cppforlife/0d8db09f65b71bf23316106b5f481e1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/bosh-dns/dns/internal/datatests/prodlike20180124/aliases.json b/src/bosh-dns/dns/internal/datatests/prodlike20180124/aliases.json | |
index b943537..1ba39e2 100644 | |
--- a/src/bosh-dns/dns/internal/datatests/prodlike20180124/aliases.json | |
+++ b/src/bosh-dns/dns/internal/datatests/prodlike20180124/aliases.json | |
@@ -1,4 +1,7 @@ | |
{ | |
+ "test.bosh": [ | |
+ "*.ig-5fc2278*.net-79382b0e.dep-966b6cac.bosh" | |
+ ], | |
"_.cell.service.cf.internal": [ | |
"_.ig-f1f0995e.net-3b01d1a9.dep-9fa89765.bosh", | |
"_.ig-f1f0995e.net-3b01d1a9.dep-fcaf863e.bosh", | |
diff --git a/src/bosh-dns/dns/internal/datatests/prodlike20180124/sample_test.go b/src/bosh-dns/dns/internal/datatests/prodlike20180124/sample_test.go | |
index c9b0928..0b117d1 100644 | |
--- a/src/bosh-dns/dns/internal/datatests/prodlike20180124/sample_test.go | |
+++ b/src/bosh-dns/dns/internal/datatests/prodlike20180124/sample_test.go | |
@@ -26,6 +26,16 @@ var _ = AfterSuite(func() { | |
}) | |
var _ = Describe("samples", func() { | |
+ FDescribe("aliases2", func() { | |
+ datatests.DescribeMatchingAnyA( | |
+ func() datatests.Server { return server }, | |
+ Entry("foo", | |
+ "test.bosh.", | |
+ "10.0.29.4", | |
+ ), | |
+ ) | |
+ }) | |
+ | |
Describe("aliases", func() { | |
datatests.DescribeMatchingAnyA( | |
func() datatests.Server { return server }, | |
diff --git a/src/bosh-dns/dns/server/criteria/criteria.go b/src/bosh-dns/dns/server/criteria/criteria.go | |
index aea3a31..676cd50 100644 | |
--- a/src/bosh-dns/dns/server/criteria/criteria.go | |
+++ b/src/bosh-dns/dns/server/criteria/criteria.go | |
@@ -106,12 +106,21 @@ func FieldMatcher(field, value string) MatcherFunc { | |
case "instanceName": | |
return func(r *record.Record) bool { return r.ID == value } | |
+ | |
+ case "instanceGroupName*": | |
+ return func(r *record.Record) bool { return strings.HasPrefix(r.Group, value) } | |
+ case "network*": | |
+ return func(r *record.Record) bool { return strings.HasPrefix(r.Network, value) } | |
+ case "deployment*": | |
+ return func(r *record.Record) bool { return strings.HasPrefix(r.Deployment, value) } | |
+ | |
case "instanceGroupName": | |
return func(r *record.Record) bool { return r.Group == value } | |
case "network": | |
return func(r *record.Record) bool { return r.Network == value } | |
case "deployment": | |
return func(r *record.Record) bool { return r.Deployment == value } | |
+ | |
case "domain": | |
return func(r *record.Record) bool { return r.Domain == value } | |
@@ -156,15 +165,27 @@ func parseCriteria(segment Segment) (Criteria, error) { | |
} | |
if segment.Instance != "" { | |
- criteriaMap.appendCriteria("instanceGroupName", segment.Instance) | |
+ if strings.HasSuffix(segment.Instance, "*") { | |
+ criteriaMap.appendCriteria("instanceGroupName*", strings.TrimSuffix(segment.Instance, "*")) | |
+ } else { | |
+ criteriaMap.appendCriteria("instanceGroupName", segment.Instance) | |
+ } | |
} | |
if segment.Network != "" { | |
- criteriaMap.appendCriteria("network", segment.Network) | |
+ if strings.HasSuffix(segment.Network, "*") { | |
+ criteriaMap.appendCriteria("network*", strings.TrimSuffix(segment.Network, "*")) | |
+ } else { | |
+ criteriaMap.appendCriteria("network", segment.Network) | |
+ } | |
} | |
if segment.Deployment != "" { | |
- criteriaMap.appendCriteria("deployment", segment.Deployment) | |
+ if strings.HasSuffix(segment.Deployment, "*") { | |
+ criteriaMap.appendCriteria("deployment*", strings.TrimSuffix(segment.Deployment, "*")) | |
+ } else { | |
+ criteriaMap.appendCriteria("deployment", segment.Deployment) | |
+ } | |
} | |
criteriaMap.appendCriteria("domain", segment.Domain) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment