Skip to content

Commit

Permalink
Addesss nonamedreturns linter violations
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis committed Jan 7, 2025
1 parent b436464 commit cd2da4b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
4 changes: 3 additions & 1 deletion coredns/gateway/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (c *Controller) updateLocalClusterIDIfNeeded(clusterID string) {
}
}

func getGatewayStatus(obj *unstructured.Unstructured) (connections []interface{}, clusterID string, gwStatus bool) {
func getGatewayStatus(obj *unstructured.Unstructured) ([]interface{}, string, bool) {
status, found, err := unstructured.NestedMap(obj.Object, "status")
if !found || err != nil {
logger.Errorf(err, "status field not found in %#v, err was", obj)
Expand All @@ -213,6 +213,8 @@ func getGatewayStatus(obj *unstructured.Unstructured) (connections []interface{}

localClusterID, found, err := unstructured.NestedString(status, "localEndpoint", "cluster_id")

var connections []interface{}

if !found || err != nil {
logger.Errorf(err, "localEndpoint->cluster_id not found in %#v, err was", status)

Expand Down
5 changes: 3 additions & 2 deletions coredns/loadbalancer/smooth_weighted_round_robin.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (lb *smoothWeightedRR) ItemCount() int {
}

// Add - adds a new unique item to the list.
func (lb *smoothWeightedRR) Add(item interface{}, weight int64) (err error) {
func (lb *smoothWeightedRR) Add(item interface{}, weight int64) error {
if item == nil {
return fmt.Errorf("item cannot be nil")
}
Expand Down Expand Up @@ -115,7 +115,8 @@ func (lb *smoothWeightedRR) nextWeightedItem() *weightedItem {
return nextSmoothWeightedItem(lb.items)
}

func nextSmoothWeightedItem(items []*weightedItem) (best *weightedItem) {
func nextSmoothWeightedItem(items []*weightedItem) *weightedItem {
var best *weightedItem
total := int64(0)

for _, item := range items {
Expand Down
4 changes: 2 additions & 2 deletions coredns/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func New(clusterStatus ClusterStatus, client dynamic.Interface) *Interface {
}
}

func (i *Interface) GetDNSRecords(namespace, name, clusterID, hostname string) (records []DNSRecord, isHeadless, found bool) {
func (i *Interface) GetDNSRecords(namespace, name, clusterID, hostname string) ([]DNSRecord, bool, bool) {
i.mutex.RLock()
defer i.mutex.RUnlock()

Expand All @@ -48,7 +48,7 @@ func (i *Interface) GetDNSRecords(namespace, name, clusterID, hostname string) (
return nil, false, found
}

records, found = i.getHeadlessRecords(serviceInfo, clusterID, hostname)
records, found := i.getHeadlessRecords(serviceInfo, clusterID, hostname)

return records, true, found
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/discovery/headless_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,10 @@ func verifyHeadlessSRVRecordsWithDig(f *framework.Framework, cluster framework.C

func createSRVQuery(f *framework.Framework, port *corev1.ServicePort, service *corev1.Service,
domain string, clusterName string, withPort, withcluster bool,
) (cmd []string, domainName string) {
cmd = []string{"dig", "+short", "SRV"}
) ([]string, string) {
cmd := []string{"dig", "+short", "SRV"}

domainName = lhframework.BuildServiceDNSName("", service.Name, f.Namespace, domain)
domainName := lhframework.BuildServiceDNSName("", service.Name, f.Namespace, domain)
clusterDNSName := domainName

if withcluster {
Expand Down
34 changes: 21 additions & 13 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@ func (f *Framework) NewEndpointForHeadlessService(cluster framework.ClusterIndex

func (f *Framework) AwaitEndpointIPs(targetCluster framework.ClusterIndex, name,
namespace string, count int,
) (ipList, hostNameList []string) {
) ([]string, []string) {
var ipList, hostNameList []string

client := framework.KubeClients[targetCluster].DiscoveryV1().EndpointSlices(namespace)
framework.By(fmt.Sprintf("Retrieving Endpoints for %s on %q", name, framework.TestContext.ClusterIDs[targetCluster]))
framework.AwaitUntil("retrieve Endpoints", func() (interface{}, error) {
Expand Down Expand Up @@ -403,10 +405,10 @@ func (f *Framework) AwaitEndpointIPs(targetCluster framework.ClusterIndex, name,

func (f *Framework) AwaitPodIngressIPs(targetCluster framework.ClusterIndex, svc *v1.Service, count int,
isLocal bool,
) (ipList, hostNameList []string) {
) ([]string, []string) {
podList := f.Framework.AwaitPodsByAppLabel(targetCluster, svc.Labels["app"], svc.Namespace, count)
hostNameList = make([]string, 0)
ipList = make([]string, 0)
hostNameList := make([]string, 0)
ipList := make([]string, 0)

for i := range len(podList.Items) {
ingressIPName := fmt.Sprintf("pod-%s", podList.Items[i].Name)
Expand All @@ -431,21 +433,21 @@ func (f *Framework) AwaitPodIngressIPs(targetCluster framework.ClusterIndex, svc

func (f *Framework) AwaitPodIPs(targetCluster framework.ClusterIndex, svc *v1.Service, count int,
isLocal bool,
) (ipList, hostNameList []string) {
) ([]string, []string) {
if framework.TestContext.GlobalnetEnabled {
return f.AwaitPodIngressIPs(targetCluster, svc, count, isLocal)
}

return f.AwaitEndpointIPs(targetCluster, svc.Name, svc.Namespace, count)
}

func (f *Framework) GetPodIPs(targetCluster framework.ClusterIndex, service *v1.Service, isLocal bool) (ipList, hostNameList []string) {
func (f *Framework) GetPodIPs(targetCluster framework.ClusterIndex, service *v1.Service, isLocal bool) ([]string, []string) {
return f.AwaitPodIPs(targetCluster, service, anyCount, isLocal)
}

func (f *Framework) AwaitEndpointIngressIPs(targetCluster framework.ClusterIndex, svc *v1.Service) (ipList, hostNameList []string) {
hostNameList = make([]string, 0)
ipList = make([]string, 0)
func (f *Framework) AwaitEndpointIngressIPs(targetCluster framework.ClusterIndex, svc *v1.Service) ([]string, []string) {
hostNameList := make([]string, 0)
ipList := make([]string, 0)

endpoint := framework.AwaitUntil("retrieve Endpoints", func() (interface{}, error) {
return framework.KubeClients[targetCluster].CoreV1().Endpoints(svc.Namespace).Get(context.TODO(), svc.Name, metav1.GetOptions{})
Expand All @@ -467,7 +469,7 @@ func (f *Framework) AwaitEndpointIngressIPs(targetCluster framework.ClusterIndex
return ipList, hostNameList
}

func (f *Framework) GetEndpointIPs(targetCluster framework.ClusterIndex, svc *v1.Service) (ipList, hostNameList []string) {
func (f *Framework) GetEndpointIPs(targetCluster framework.ClusterIndex, svc *v1.Service) ([]string, []string) {
if framework.TestContext.GlobalnetEnabled {
return f.AwaitEndpointIngressIPs(targetCluster, svc)
}
Expand Down Expand Up @@ -548,7 +550,9 @@ func create(f *Framework, cluster framework.ClusterIndex, statefulSet *appsv1.St

func (f *Framework) AwaitEndpointSlices(targetCluster framework.ClusterIndex, name, namespace string,
expSliceCount, expReadyCount int,
) (endpointSliceList *discovery.EndpointSliceList) {
) *discovery.EndpointSliceList {
var endpointSliceList *discovery.EndpointSliceList

ep := framework.KubeClients[targetCluster].DiscoveryV1().EndpointSlices(namespace)
labelMap := map[string]string{
discovery.LabelManagedBy: constants.LabelValueManagedBy,
Expand Down Expand Up @@ -604,7 +608,9 @@ func (f *Framework) SetNginxStatefulSetReplicas(cluster framework.ClusterIndex,
return result
}

func (f *Framework) GetHealthCheckIPInfo(cluster framework.ClusterIndex) (endpointName, healthCheckIP string) {
func (f *Framework) GetHealthCheckIPInfo(cluster framework.ClusterIndex) (string, string) {
var endpointName, healthCheckIP string

framework.AwaitUntil("Get healthCheckIP", func() (interface{}, error) {
unstructuredEndpointList, err := EndpointClients[cluster].List(context.TODO(), metav1.ListOptions{})
return unstructuredEndpointList, err
Expand Down Expand Up @@ -636,7 +642,9 @@ func (f *Framework) GetHealthCheckIPInfo(cluster framework.ClusterIndex) (endpoi
return endpointName, healthCheckIP
}

func (f *Framework) GetHealthCheckEnabledInfo(cluster framework.ClusterIndex) (healthCheckEnabled bool) {
func (f *Framework) GetHealthCheckEnabledInfo(cluster framework.ClusterIndex) bool {
var healthCheckEnabled bool

framework.AwaitUntil("Get healthCheckEnabled Configuration", func() (interface{}, error) {
unstructuredSubmarinerConfig, err := SubmarinerClients[cluster].Get(context.TODO(),
"submariner", metav1.GetOptions{})
Expand Down

0 comments on commit cd2da4b

Please sign in to comment.