Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Nov 13, 2023
1 parent 9ae6a70 commit e0bef38
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
19 changes: 11 additions & 8 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ func waitForDeployments(k8sClient client.Client) error {
}

for _, key := range deploymentKeys {
err := wait.Poll(retryInterval, timeout, func() (bool, error) {
return utils.CheckDeploymentAvailable(k8sClient, key)
immediate := true
err := wait.PollUntilContextTimeout(context.Background(), retryInterval, timeout, immediate, func(ctx context.Context) (bool, error) {
return utils.CheckDeploymentAvailable(ctx, k8sClient, key)
})

if err != nil {
Expand Down Expand Up @@ -147,10 +148,11 @@ func deployKuadrantOperator(k8sClient client.Client) error {
var installPlanKey client.ObjectKey

// Wait for the install process to be completed
immediate := true
logf.Log.Info("Waiting for the kuadrant operator installation")
err = wait.Poll(time.Second*2, time.Second*20, func() (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), time.Second*2, time.Second*20, immediate, func(ctx context.Context) (bool, error) {
existingSubs := &operators.Subscription{}
err := k8sClient.Get(context.Background(), client.ObjectKeyFromObject(subs), existingSubs)
err := k8sClient.Get(ctx, client.ObjectKeyFromObject(subs), existingSubs)
if err != nil {
if apierrors.IsNotFound(err) {
logf.Log.Info("Subscription not available", "name", client.ObjectKeyFromObject(subs))
Expand All @@ -176,9 +178,9 @@ func deployKuadrantOperator(k8sClient client.Client) error {
}

logf.Log.Info("Waiting for the install plan", "name", installPlanKey)
err = wait.Poll(time.Second*5, time.Minute*2, func() (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), time.Second*5, time.Minute*2, immediate, func(ctx context.Context) (bool, error) {
ip := &operators.InstallPlan{}
err := k8sClient.Get(context.Background(), installPlanKey, ip)
err := k8sClient.Get(ctx, installPlanKey, ip)
if err != nil {
if apierrors.IsNotFound(err) {
logf.Log.Info("Install plan not available", "name", installPlanKey)
Expand Down Expand Up @@ -230,8 +232,9 @@ func createNamespace(k8sClient client.Client) error {

retryInterval := time.Second * 2
timeout := time.Second * 20
return wait.Poll(retryInterval, timeout, func() (bool, error) {
err := k8sClient.Get(context.Background(), types.NamespacedName{Name: installNamespace}, &corev1.Namespace{})
immediate := true
return wait.PollUntilContextTimeout(context.Background(), retryInterval, timeout, immediate, func(ctx context.Context) (bool, error) {
err := k8sClient.Get(ctx, types.NamespacedName{Name: installNamespace}, &corev1.Namespace{})
if err != nil && apierrors.IsNotFound(err) {
return false, nil
}
Expand Down
2 changes: 1 addition & 1 deletion make/lint.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GOLANGCI-LINT=$(PROJECT_PATH)/bin/golangci-lint
$(GOLANGCI-LINT):
mkdir -p $(PROJECT_PATH)/bin
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.41.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.55.2

.PHONY: golangci-lint
golangci-lint: $(GOLANGCI-LINT)
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/external_resource_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
package utils

import (
"io/ioutil"
"io"
"os"
)

Expand All @@ -26,13 +26,13 @@ import (
// - Files
func ReadExternalResource(resource string) ([]byte, error) {
if resource == "@" {
return ioutil.ReadAll(os.Stdin)
return io.ReadAll(os.Stdin)
}

if url, isURL := ParseURL(resource); isURL {
return ReadURL(url)
}

// Defaulting to filepath
return ioutil.ReadFile(resource)
return os.ReadFile(resource)
}
4 changes: 2 additions & 2 deletions pkg/utils/http_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
package utils

import (
"io/ioutil"
"io"
"net/http"
"net/url"
)
Expand All @@ -32,7 +32,7 @@ func ReadURL(location *url.URL) ([]byte, error) {
if err != nil {
return nil, err
}
data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
defer resp.Body.Close()
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/k8s_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ func IsDeploymentAvailable(dc *appsv1.Deployment) bool {
return false
}

func CheckDeploymentAvailable(k8sClient client.Client, key types.NamespacedName) (bool, error) {
func CheckDeploymentAvailable(ctx context.Context, k8sClient client.Client, key types.NamespacedName) (bool, error) {
existingDeployment := &appsv1.Deployment{}
err := k8sClient.Get(context.Background(), key, existingDeployment)
err := k8sClient.Get(ctx, key, existingDeployment)
if err != nil {
if apierrors.IsNotFound(err) {
logf.Log.Info("Deployment not available", "name", key.Name)
Expand Down

0 comments on commit e0bef38

Please sign in to comment.