Skip to content

Commit

Permalink
making linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
metlos committed Aug 26, 2024
1 parent 28a9295 commit a718700
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
3 changes: 1 addition & 2 deletions controllers/toolchaincluster/healthchecker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"testing"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
"github.com/codeready-toolchain/toolchain-common/pkg/cluster"
"github.com/codeready-toolchain/toolchain-common/pkg/test"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -58,7 +57,7 @@ func TestClusterHealthChecks(t *testing.T) {
for k, tc := range tests {
t.Run(k, func(t *testing.T) {
// given
tcType, sec := newToolchainCluster(t, tc.tcType, tcNs, tc.apiEndPoint, toolchainv1alpha1.ToolchainClusterStatus{}, false)
tcType, sec := newToolchainCluster(t, tc.tcType, tcNs, tc.apiEndPoint)
cl := test.NewFakeClient(t, tcType, sec)
reset := setupCachedClusters(t, cl, tcType)
defer reset()
Expand Down
20 changes: 10 additions & 10 deletions controllers/toolchaincluster/toolchaincluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestClusterControllerChecks(t *testing.T) {

t.Run("ToolchainCluster not found", func(t *testing.T) {
// given
NotFound, sec := newToolchainCluster(t, "notfound", tcNs, "http://not-found.com", toolchainv1alpha1.ToolchainClusterStatus{}, false)
NotFound, sec := newToolchainCluster(t, "notfound", tcNs, "http://not-found.com")

cl := test.NewFakeClient(t, sec)
reset := setupCachedClusters(t, cl, NotFound)
Expand All @@ -62,7 +62,7 @@ func TestClusterControllerChecks(t *testing.T) {

t.Run("Error while getting ToolchainCluster", func(t *testing.T) {
// given
tc, sec := newToolchainCluster(t, "tc", tcNs, "http://tc.com", toolchainv1alpha1.ToolchainClusterStatus{}, false)
tc, sec := newToolchainCluster(t, "tc", tcNs, "http://tc.com")

cl := test.NewFakeClient(t, sec)
cl.MockGet = func(ctx context.Context, key runtimeclient.ObjectKey, obj runtimeclient.Object, opts ...runtimeclient.GetOption) error {
Expand All @@ -83,7 +83,7 @@ func TestClusterControllerChecks(t *testing.T) {

t.Run("reconcile successful and requeued", func(t *testing.T) {
// given
stable, sec := newToolchainCluster(t, "stable", tcNs, "https://cluster.com", toolchainv1alpha1.ToolchainClusterStatus{}, false)
stable, sec := newToolchainCluster(t, "stable", tcNs, "https://cluster.com")

cl := test.NewFakeClient(t, stable, sec)
reset := setupCachedClusters(t, cl, stable)
Expand All @@ -102,7 +102,7 @@ func TestClusterControllerChecks(t *testing.T) {

t.Run("toolchain cluster cache not found", func(t *testing.T) {
// given
unstable, _ := newToolchainCluster(t, "unstable", tcNs, "http://unstable.com", toolchainv1alpha1.ToolchainClusterStatus{}, false)
unstable, _ := newToolchainCluster(t, "unstable", tcNs, "http://unstable.com")

cl := test.NewFakeClient(t, unstable)
controller, req := prepareReconcile(unstable, cl, requeAfter)
Expand All @@ -117,7 +117,7 @@ func TestClusterControllerChecks(t *testing.T) {

t.Run("error while updating a toolchain cluster status on cache not found", func(t *testing.T) {
// given
stable, _ := newToolchainCluster(t, "stable", tcNs, "https://cluster.com", toolchainv1alpha1.ToolchainClusterStatus{}, false)
stable, _ := newToolchainCluster(t, "stable", tcNs, "https://cluster.com")

cl := test.NewFakeClient(t, stable)
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
Expand All @@ -137,7 +137,7 @@ func TestClusterControllerChecks(t *testing.T) {

t.Run("error while updating a toolchain cluster status when health-check failed", func(t *testing.T) {
// given
stable, sec := newToolchainCluster(t, "stable", tcNs, "https://cluster.com", toolchainv1alpha1.ToolchainClusterStatus{}, false)
stable, sec := newToolchainCluster(t, "stable", tcNs, "https://cluster.com")
expectedErr := fmt.Errorf("my test error")
cl := test.NewFakeClient(t, stable, sec)
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
Expand All @@ -163,7 +163,7 @@ func TestClusterControllerChecks(t *testing.T) {
func TestGetClusterHealth(t *testing.T) {
t.Run("Check health default", func(t *testing.T) {
// given
stable, sec := newToolchainCluster(t, "stable", "test-namespace", "https://cluster.com", toolchainv1alpha1.ToolchainClusterStatus{}, false)
stable, sec := newToolchainCluster(t, "stable", "test-namespace", "https://cluster.com")

cl := test.NewFakeClient(t, stable, sec)
reset := setupCachedClusters(t, cl, stable)
Expand All @@ -184,7 +184,7 @@ func TestGetClusterHealth(t *testing.T) {
})
t.Run("get health condition when health obtained is false ", func(t *testing.T) {
// given
stable, sec := newToolchainCluster(t, "stable", "test-namespace", "https://cluster.com", toolchainv1alpha1.ToolchainClusterStatus{}, false)
stable, sec := newToolchainCluster(t, "stable", "test-namespace", "https://cluster.com")

cl := test.NewFakeClient(t, stable, sec)
reset := setupCachedClusters(t, cl, stable)
Expand Down Expand Up @@ -238,8 +238,8 @@ func setupCachedClusters(t *testing.T, cl *test.FakeClient, clusters ...*toolcha
}
}

func newToolchainCluster(t *testing.T, name, tcNs string, apiEndpoint string, status toolchainv1alpha1.ToolchainClusterStatus, insecureTls bool) (*toolchainv1alpha1.ToolchainCluster, *corev1.Secret) {
toolchainCluster, secret := test.NewToolchainClusterWithEndpoint(t, name, tcNs, "test-namespace", "secret", apiEndpoint, status, insecureTls)
func newToolchainCluster(t *testing.T, name, tcNs string, apiEndpoint string) (*toolchainv1alpha1.ToolchainCluster, *corev1.Secret) {
toolchainCluster, secret := test.NewToolchainClusterWithEndpoint(t, name, tcNs, "test-namespace", "secret", apiEndpoint, toolchainv1alpha1.ToolchainClusterStatus{}, false)
return toolchainCluster, secret
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/cluster/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ const (
// labelClusterRolePrefix is the prefix that defines the cluster role as label key
labelClusterRolePrefix = "cluster-role"

toolchainAPIQPS = 20.0
toolchainAPIBurst = 30
toolchainTokenKey = "token"
// These are not used
// toolchainAPIQPS = 20.0
// toolchainAPIBurst = 30
// toolchainTokenKey = "token"
)

// ToolchainClusterService manages cached cluster kube clients and related ToolchainCluster CRDs
Expand Down

0 comments on commit a718700

Please sign in to comment.