remove unused functions (#2873)

This commit is contained in:
Chris O'Haver 2019-06-09 03:09:55 -04:00 committed by Miek Gieben
parent 458e778113
commit bd83f74deb
2 changed files with 0 additions and 97 deletions

View file

@ -271,33 +271,6 @@ func (k *Kubernetes) Records(ctx context.Context, state request.Request, exact b
return services, err
}
// serviceFQDN returns the k8s cluster dns spec service FQDN for the service (or endpoint) object.
func serviceFQDN(obj meta.Object, zone string) string {
return dnsutil.Join(obj.GetName(), obj.GetNamespace(), Svc, zone)
}
// podFQDN returns the k8s cluster dns spec FQDN for the pod.
func podFQDN(p *object.Pod, zone string) string {
if strings.Contains(p.PodIP, ".") {
name := strings.Replace(p.PodIP, ".", "-", -1)
return dnsutil.Join(name, p.GetNamespace(), Pod, zone)
}
name := strings.Replace(p.PodIP, ":", "-", -1)
return dnsutil.Join(name, p.GetNamespace(), Pod, zone)
}
// endpointFQDN returns a list of k8s cluster dns spec service FQDNs for each subset in the endpoint.
func endpointFQDN(ep *object.Endpoints, zone string, endpointNameMode bool) []string {
var names []string
for _, ss := range ep.Subsets {
for _, addr := range ss.Addresses {
names = append(names, dnsutil.Join(endpointHostname(addr, endpointNameMode), serviceFQDN(ep, zone)))
}
}
return names
}
func endpointHostname(addr object.EndpointAddress, endpointNameMode bool) string {
if addr.Hostname != "" {
return addr.Hostname

View file

@ -355,73 +355,3 @@ func TestServicesAuthority(t *testing.T) {
}
}
}
func TestServiceFQDN(t *testing.T) {
fqdn := serviceFQDN(
&object.Service{
Name: "svc1",
Namespace: "testns",
}, "cluster.local")
expected := "svc1.testns.svc.cluster.local."
if fqdn != expected {
t.Errorf("Expected '%v', got '%v'.", expected, fqdn)
}
}
func TestPodFQDN(t *testing.T) {
fqdn := podFQDN(
&object.Pod{
Name: "pod1",
Namespace: "testns",
PodIP: "10.10.0.10",
}, "cluster.local")
expected := "10-10-0-10.testns.pod.cluster.local."
if fqdn != expected {
t.Errorf("Expected '%v', got '%v'.", expected, fqdn)
}
fqdn = podFQDN(
&object.Pod{
Name: "pod1",
Namespace: "testns",
PodIP: "aaaa:bbbb:cccc::zzzz",
}, "cluster.local")
expected = "aaaa-bbbb-cccc--zzzz.testns.pod.cluster.local."
if fqdn != expected {
t.Errorf("Expected '%v', got '%v'.", expected, fqdn)
}
}
func TestEndpointFQDN(t *testing.T) {
fqdns := endpointFQDN(
&object.Endpoints{
Subsets: []object.EndpointSubset{
{
Addresses: []object.EndpointAddress{
{
IP: "172.0.0.1",
Hostname: "ep1a",
},
{
IP: "172.0.0.2",
},
},
},
},
Name: "svc1",
Namespace: "testns",
}, "cluster.local", false)
expected := []string{
"ep1a.svc1.testns.svc.cluster.local.",
"172-0-0-2.svc1.testns.svc.cluster.local.",
}
for i := range fqdns {
if fqdns[i] != expected[i] {
t.Errorf("Expected '%v', got '%v'.", expected[i], fqdns[i])
}
}
}