Skip to content

Commit 5885ce3

Browse files
committed
lint: enable noctx linter
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent ac4232e commit 5885ce3

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ linters:
1818
- ineffassign
1919
- makezero
2020
- misspell
21+
- noctx
2122
- nolintlint
2223
- revive
2324
- staticcheck

util/testutil/helpers/azurite.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package helpers
22

33
import (
4+
"context"
45
"fmt"
56
"net"
67
"net/http"
@@ -63,7 +64,7 @@ func NewAzuriteServer(t *testing.T, sb integration.Sandbox, opts AzuriteOpts) (a
6364
if err != nil {
6465
return "", nil, err
6566
}
66-
if err = waitAzurite(address, 15*time.Second); err != nil {
67+
if err = waitAzurite(sb.Context(), address, 15*time.Second); err != nil {
6768
azuriteStop()
6869
return "", nil, errors.Wrapf(err, "azurite did not start up: %s", integration.FormatLogs(sb.Logs()))
6970
}
@@ -72,11 +73,16 @@ func NewAzuriteServer(t *testing.T, sb integration.Sandbox, opts AzuriteOpts) (a
7273
return
7374
}
7475

75-
func waitAzurite(address string, d time.Duration) error {
76+
func waitAzurite(ctx context.Context, address string, d time.Duration) error {
7677
step := 1 * time.Second
7778
i := 0
7879
for {
79-
if resp, err := http.Get(fmt.Sprintf("%s?comp=list", address)); err == nil {
80+
req, err := http.NewRequest("GET", fmt.Sprintf("%s?comp=list", address), nil)
81+
if err != nil {
82+
return errors.Wrapf(err, "failed to create request")
83+
}
84+
req = req.WithContext(ctx)
85+
if resp, err := http.DefaultClient.Do(req); err == nil {
8086
resp.Body.Close()
8187
break
8288
}

util/testutil/helpers/minio.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package helpers
22

33
import (
4+
"context"
45
"crypto/rand"
56
"fmt"
67
"net"
@@ -67,7 +68,7 @@ func NewMinioServer(t *testing.T, sb integration.Sandbox, opts MinioOpts) (addre
6768
if err != nil {
6869
return "", "", nil, err
6970
}
70-
if err = waitMinio(address, 15*time.Second); err != nil {
71+
if err = waitMinio(sb.Context(), address, 15*time.Second); err != nil {
7172
minioStop()
7273
return "", "", nil, errors.Wrapf(err, "minio did not start up: %s", integration.FormatLogs(sb.Logs()))
7374
}
@@ -100,11 +101,16 @@ func NewMinioServer(t *testing.T, sb integration.Sandbox, opts MinioOpts) (addre
100101
return
101102
}
102103

103-
func waitMinio(address string, d time.Duration) error {
104+
func waitMinio(ctx context.Context, address string, d time.Duration) error {
104105
step := 1 * time.Second
105106
i := 0
106107
for {
107-
if resp, err := http.Get(fmt.Sprintf("%s/minio/health/live", address)); err == nil {
108+
req, err := http.NewRequest("GET", fmt.Sprintf("%s/minio/health/live", address), nil)
109+
if err != nil {
110+
return errors.Wrapf(err, "failed to create request")
111+
}
112+
req = req.WithContext(ctx)
113+
if resp, err := http.DefaultClient.Do(req); err == nil {
108114
resp.Body.Close()
109115
break
110116
}

0 commit comments

Comments
 (0)