From 28268c7b96f118466053b94fa1a96227bbe2557a Mon Sep 17 00:00:00 2001 From: Jaskaran Sarkaria Date: Wed, 28 Aug 2024 16:17:00 +0100 Subject: [PATCH] =?UTF-8?q?perf:=20=E2=9A=A1=EF=B8=8F=20call=20GetAllNodes?= =?UTF-8?q?=20once=20(#613)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf: ⚡️ call GetAllNodes once --- pkg/cluster/cluster.go | 2 +- pkg/cluster/node.go | 1 - pkg/util/testutils.go | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 28f42750..7b668887 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -62,7 +62,7 @@ func NewCluster(c *client.KubeClient) (*Cluster, error) { return nil, err } - oldestNode, err := getOldestNode(c) + oldestNode, err := oldestNode(nodes) if err != nil { return nil, err } diff --git a/pkg/cluster/node.go b/pkg/cluster/node.go index d8e46f8b..6ffe4ce5 100644 --- a/pkg/cluster/node.go +++ b/pkg/cluster/node.go @@ -90,7 +90,6 @@ func GetAllNodes(c *client.KubeClient) ([]v1.Node, error) { return n, nil } -// getOldestNode returns the oldest node in a cluster func getOldestNode(c *client.KubeClient) (v1.Node, error) { nodes, err := GetAllNodes(c) if err != nil { diff --git a/pkg/util/testutils.go b/pkg/util/testutils.go index 7ac52478..7968b24b 100644 --- a/pkg/util/testutils.go +++ b/pkg/util/testutils.go @@ -1,7 +1,6 @@ package util import ( - "fmt" "os" "strings" "testing" @@ -14,7 +13,7 @@ func FileContainsString(t *testing.T, filename string, searchString string) { } if !(strings.Contains(string(contents), searchString)) { - t.Errorf(fmt.Sprintf("Didn't find string: %s in file: %s", searchString, filename)) + t.Errorf("Didn't find string: %s in file: %s", searchString, filename) } }