diff options
Diffstat (limited to 'middleware/kubernetes/path.go')
-rw-r--r-- | middleware/kubernetes/path.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/middleware/kubernetes/path.go b/middleware/kubernetes/path.go new file mode 100644 index 000000000..18c26f949 --- /dev/null +++ b/middleware/kubernetes/path.go @@ -0,0 +1,17 @@ +package kubernetes + +import ( + "strings" + + "github.com/miekg/dns" +) + +// Domain is the opposite of Path. +func (k Kubernetes) Domain(s string) string { + l := strings.Split(s, "/") + // start with 1, to strip /skydns + for i, j := 1, len(l)-1; i < j; i, j = i+1, j-1 { + l[i], l[j] = l[j], l[i] + } + return dns.Fqdn(strings.Join(l[1:len(l)-1], ".")) +} |