Skip to content

Commit a0cf7b5

Browse files
authored
Merge pull request #126 from rajansandeep/cleanuputils
Cleanup naming in utils for better clarity
2 parents 73adf6a + a18a972 commit a0cf7b5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

utils/utils.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ import (
1414
)
1515

1616
const (
17-
coreDNSDomain = "cluster.local"
18-
coreDNSIP = "10.96.0.10"
17+
dnsDomain = "cluster.local"
18+
dnsIP = "10.96.0.10"
1919
)
2020

21-
// getCoreDNSService fetches the CoreDNS Service
22-
func getCoreDNSService(ctx context.Context, c client.Client) (*corev1.Service, error) {
21+
// getKubernetesService fetches the Kubernetes Service
22+
func getKubernetesService(ctx context.Context, c client.Client) (*corev1.Service, error) {
2323
kubernetesService := &corev1.Service{}
2424
id := client.ObjectKey{Namespace: metav1.NamespaceDefault, Name: "kubernetes"}
2525

26-
// Get the CoreDNS Service
26+
// Get the Kubernetes Service
2727
err := c.Get(ctx, id, kubernetesService)
2828

2929
return kubernetesService, err
@@ -33,14 +33,14 @@ func getCoreDNSService(ctx context.Context, c client.Client) (*corev1.Service, e
3333
// It is usually the 10th address to the Kubernetes Service Cluster IP
3434
// If the Kubernetes Service Cluster IP is not found, we default it to be "10.96.0.10"
3535
func FindDNSClusterIP(ctx context.Context, c client.Client) (string, error) {
36-
kubernetesService, err := getCoreDNSService(ctx, c)
36+
kubernetesService, err := getKubernetesService(ctx, c)
3737
if err != nil && !apierrors.IsNotFound(err) {
3838
return "", err
3939
}
4040

4141
if apierrors.IsNotFound(err) {
4242
// If it cannot determine the Cluster IP, we default it to "10.96.0.10"
43-
return coreDNSIP, nil
43+
return dnsIP, nil
4444
}
4545

4646
ip := net.ParseIP(kubernetesService.Spec.ClusterIP)
@@ -49,7 +49,7 @@ func FindDNSClusterIP(ctx context.Context, c client.Client) (string, error) {
4949
}
5050

5151
// The kubernetes Service ClusterIP is the 1st IP in the Service Subnet.
52-
// Increment the right-most byte by 9 to get to the 10th address, canonically used for CoreDNS.
52+
// Increment the right-most byte by 9 to get to the 10th address, canonically used for DNS.
5353
// This works for both IPV4, IPV6, and 16-byte IPV4 addresses.
5454
ip[len(ip)-1] += 9
5555

@@ -67,14 +67,14 @@ func GetDNSDomain() string {
6767
cname, err := net.LookupCNAME(svc)
6868
if err != nil {
6969
// If it cannot determine the domain, we default it to "cluster.local"
70-
klog.Infof("determined DNS Domain for cluster should be %q", coreDNSDomain)
71-
return coreDNSDomain
70+
klog.Infof("determined DNS Domain for cluster should be %q", dnsDomain)
71+
return dnsDomain
7272
}
7373

7474
domain := strings.TrimPrefix(cname, svc)
75-
domain = strings.TrimSuffix(coreDNSDomain, ".")
75+
domain = strings.TrimSuffix(dnsDomain, ".")
7676

77-
klog.Infof("determined DNS Domain for CoreDNS should be %q", domain)
77+
klog.Infof("determined DNS Domain for DNS should be %q", domain)
7878

7979
return domain
8080
}

0 commit comments

Comments
 (0)