Skip to content

Commit

Permalink
lint: enable noctx linter
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed May 15, 2024
1 parent ac4232e commit 5885ce3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ linters:
- ineffassign
- makezero
- misspell
- noctx
- nolintlint
- revive
- staticcheck
Expand Down
12 changes: 9 additions & 3 deletions util/testutil/helpers/azurite.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package helpers

import (
"context"
"fmt"
"net"
"net/http"
Expand Down Expand Up @@ -63,7 +64,7 @@ func NewAzuriteServer(t *testing.T, sb integration.Sandbox, opts AzuriteOpts) (a
if err != nil {
return "", nil, err
}
if err = waitAzurite(address, 15*time.Second); err != nil {
if err = waitAzurite(sb.Context(), address, 15*time.Second); err != nil {
azuriteStop()
return "", nil, errors.Wrapf(err, "azurite did not start up: %s", integration.FormatLogs(sb.Logs()))
}
Expand All @@ -72,11 +73,16 @@ func NewAzuriteServer(t *testing.T, sb integration.Sandbox, opts AzuriteOpts) (a
return
}

func waitAzurite(address string, d time.Duration) error {
func waitAzurite(ctx context.Context, address string, d time.Duration) error {
step := 1 * time.Second
i := 0
for {
if resp, err := http.Get(fmt.Sprintf("%s?comp=list", address)); err == nil {
req, err := http.NewRequest("GET", fmt.Sprintf("%s?comp=list", address), nil)
if err != nil {
return errors.Wrapf(err, "failed to create request")
}
req = req.WithContext(ctx)
if resp, err := http.DefaultClient.Do(req); err == nil {
resp.Body.Close()
break
}
Expand Down
12 changes: 9 additions & 3 deletions util/testutil/helpers/minio.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package helpers

import (
"context"
"crypto/rand"
"fmt"
"net"
Expand Down Expand Up @@ -67,7 +68,7 @@ func NewMinioServer(t *testing.T, sb integration.Sandbox, opts MinioOpts) (addre
if err != nil {
return "", "", nil, err
}
if err = waitMinio(address, 15*time.Second); err != nil {
if err = waitMinio(sb.Context(), address, 15*time.Second); err != nil {
minioStop()
return "", "", nil, errors.Wrapf(err, "minio did not start up: %s", integration.FormatLogs(sb.Logs()))
}
Expand Down Expand Up @@ -100,11 +101,16 @@ func NewMinioServer(t *testing.T, sb integration.Sandbox, opts MinioOpts) (addre
return
}

func waitMinio(address string, d time.Duration) error {
func waitMinio(ctx context.Context, address string, d time.Duration) error {
step := 1 * time.Second
i := 0
for {
if resp, err := http.Get(fmt.Sprintf("%s/minio/health/live", address)); err == nil {
req, err := http.NewRequest("GET", fmt.Sprintf("%s/minio/health/live", address), nil)
if err != nil {
return errors.Wrapf(err, "failed to create request")
}
req = req.WithContext(ctx)
if resp, err := http.DefaultClient.Do(req); err == nil {
resp.Body.Close()
break
}
Expand Down

0 comments on commit 5885ce3

Please sign in to comment.