Skip to content

Commit 840fb8a

Browse files
authored
CLOUDP-105826: Update golangci-lint to 1.43 (#266)
1 parent 43497be commit 840fb8a

File tree

11 files changed

+19
-48
lines changed

11 files changed

+19
-48
lines changed

.github/workflows/pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v2
1515
- name: lint
16-
uses: golangci/golangci-lint-action@v2.5.2
16+
uses: golangci/golangci-lint-action@v2
1717
with:
18-
version: v1.40.1
18+
version: v1.43.0
1919

2020
tests-on-unix:
2121
needs: golangci-lint # run after golangci-lint action to not produce duplicated errors
@@ -33,7 +33,7 @@ jobs:
3333
with:
3434
go-version: ${{ matrix.golang }}
3535
- name: Cache Dependencies
36-
uses: actions/cache@v2.1.6
36+
uses: actions/cache@v2
3737
with:
3838
path: ~/go/pkg/mod
3939
key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }}

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SOURCE_FILES?=./...
22
PKG_NAME=mongodbatlas
3-
GOLANGCI_VERSION=v1.40.1
3+
GOLANGCI_VERSION=v1.43.0
44
COVERAGE=coverage.out
55

66
export GO111MODULE := on

mongodbatlas/accesslist_api_keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"net/http"
2121
)
2222

23-
const accessListAPIKeysPath = "api/atlas/v1.0/orgs/%s/apiKeys/%s/accessList"
23+
const accessListAPIKeysPath = "api/atlas/v1.0/orgs/%s/apiKeys/%s/accessList" //nolint:gosec // This is a path
2424

2525
// AccessListAPIKeysService is an interface for interfacing with the AccessList API Keys
2626
// endpoints of the MongoDB Atlas API.

mongodbatlas/accesslist_api_keys_test.go

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ import (
2323
"github.com/go-test/deep"
2424
)
2525

26+
const (
27+
apiKeyID = "API-KEY-ID" //nolint:gosec // ID and not an actual key
28+
ipAddress = "IP-ADDRESS"
29+
)
30+
2631
func TestAccessListAPIKeys_List(t *testing.T) {
2732
client, mux, teardown := setup()
2833
defer teardown()
2934

30-
orgID := "ORG-ID"
31-
apiKeyID := "API-KEY-ID"
32-
3335
mux.HandleFunc(fmt.Sprintf("/"+accessListAPIKeysPath, orgID, apiKeyID), func(w http.ResponseWriter, r *http.Request) {
3436
testMethod(t, r, http.MethodGet)
3537
fmt.Fprint(w, `{
@@ -127,10 +129,6 @@ func TestAccessListAPIKeys_Get(t *testing.T) {
127129
client, mux, teardown := setup()
128130
defer teardown()
129131

130-
orgID := "ORG-ID"
131-
apiKeyID := "API-KEY-ID"
132-
ipAddress := "IP-ADDRESS"
133-
134132
mux.HandleFunc(fmt.Sprintf("/"+accessListAPIKeysPath+"/%s", orgID, apiKeyID, ipAddress), func(w http.ResponseWriter, r *http.Request) {
135133
testMethod(t, r, http.MethodGet)
136134
fmt.Fprint(w, `{
@@ -174,9 +172,6 @@ func TestAccessListAPIKeys_Create(t *testing.T) {
174172
client, mux, teardown := setup()
175173
defer teardown()
176174

177-
orgID := "ORG-ID"
178-
apiKeyID := "API-KEY-ID"
179-
180175
createRequest := []*AccessListAPIKeysReq{
181176
{
182177
IPAddress: "77.54.32.11",
@@ -297,10 +292,6 @@ func TestAccessListAPIKeys_Delete(t *testing.T) {
297292
client, mux, teardown := setup()
298293
defer teardown()
299294

300-
orgID := "ORG-ID"
301-
apiKeyID := "API-KEY-ID"
302-
ipAddress := "IP-ADDRESS"
303-
304295
mux.HandleFunc(fmt.Sprintf("/"+accessListAPIKeysPath+"/%s", orgID, apiKeyID, ipAddress), func(w http.ResponseWriter, r *http.Request) {
305296
testMethod(t, r, http.MethodDelete)
306297
})

mongodbatlas/api_keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"net/url"
2222
)
2323

24-
const apiKeysPath = "api/atlas/v1.0/orgs/%s/apiKeys"
24+
const apiKeysPath = "api/atlas/v1.0/orgs/%s/apiKeys" //nolint:gosec // This is a path
2525

2626
// APIKeysService is an interface for interfacing with the APIKeys
2727
// endpoints of the MongoDB Atlas API.

mongodbatlas/api_keys_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ func TestAPIKeys_Create(t *testing.T) {
235235
client, mux, teardown := setup()
236236
defer teardown()
237237

238-
orgID := "1"
239-
240238
createRequest := &APIKeyInput{
241239
Desc: "test-apiKey",
242240
Roles: []string{"GROUP_OWNER"},
@@ -382,9 +380,6 @@ func TestAPIKeys_Delete(t *testing.T) {
382380
client, mux, teardown := setup()
383381
defer teardown()
384382

385-
orgID := "1"
386-
apiKeyID := "5c47503320eef5699e1cce8d"
387-
388383
mux.HandleFunc(fmt.Sprintf("/api/atlas/v1.0/orgs/%s/apiKeys/%s", orgID, apiKeyID), func(w http.ResponseWriter, r *http.Request) {
389384
testMethod(t, r, http.MethodDelete)
390385
})

mongodbatlas/mongodbatlas.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"errors"
2222
"fmt"
2323
"io"
24-
"io/ioutil"
2524
"log"
2625
"net/http"
2726
"net/url"
@@ -448,7 +447,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Res
448447
// won't reuse it anyway.
449448
const maxBodySlurpSize = 2 << 10
450449
if resp.ContentLength == -1 || resp.ContentLength <= maxBodySlurpSize {
451-
_, _ = io.CopyN(ioutil.Discard, resp.Body, maxBodySlurpSize)
450+
_, _ = io.CopyN(io.Discard, resp.Body, maxBodySlurpSize)
452451
}
453452

454453
resp.Body.Close()
@@ -519,7 +518,7 @@ func CheckResponse(r *http.Response) error {
519518
}
520519

521520
errorResponse := &ErrorResponse{Response: r}
522-
data, err := ioutil.ReadAll(r.Body)
521+
data, err := io.ReadAll(r.Body)
523522
if err == nil && len(data) > 0 {
524523
err := json.Unmarshal(data, errorResponse)
525524
if err != nil {

mongodbatlas/mongodbatlas_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"encoding/json"
2020
"errors"
2121
"fmt"
22-
"io/ioutil"
22+
"io"
2323
"net/http"
2424
"net/http/httptest"
2525
"net/http/httputil"
@@ -165,7 +165,7 @@ func TestNewRequest_withUserData(t *testing.T) {
165165
}
166166

167167
// test body was JSON encoded
168-
body, _ := ioutil.ReadAll(req.Body)
168+
body, _ := io.ReadAll(req.Body)
169169
if string(body) != outBody {
170170
t.Errorf("NewRequest(%v)Body = %v, expected %v", inBody, string(body), outBody)
171171
}
@@ -427,7 +427,7 @@ func TestCheckResponse(t *testing.T) {
427427
res := &http.Response{
428428
Request: &http.Request{},
429429
StatusCode: http.StatusBadRequest,
430-
Body: ioutil.NopCloser(
430+
Body: io.NopCloser(
431431
strings.NewReader(
432432
`{"error":409, "errorCode": "GROUP_ALREADY_EXISTS", "reason":"Conflict", "detail":"A group with name \"Test\" already exists"}`,
433433
),
@@ -456,7 +456,7 @@ func TestCheckResponse_noBody(t *testing.T) {
456456
res := &http.Response{
457457
Request: &http.Request{},
458458
StatusCode: http.StatusBadRequest,
459-
Body: ioutil.NopCloser(strings.NewReader("")),
459+
Body: io.NopCloser(strings.NewReader("")),
460460
}
461461
var target *ErrorResponse
462462
if !errors.As(CheckResponse(res), &target) {

mongodbatlas/project_api_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"net/http"
2121
)
2222

23-
const projectAPIKeysPath = "api/atlas/v1.0/groups/%s/apiKeys"
23+
const projectAPIKeysPath = "api/atlas/v1.0/groups/%s/apiKeys" //nolint:gosec // This is a path
2424

2525
// ProjectAPIKeysService is an interface for interfacing with the APIKeys
2626
// endpoints of the MongoDB Atlas API.

mongodbatlas/whitelist_api_keys.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"net/http"
2121
)
2222

23-
const whitelistAPIKeysPath = "api/atlas/v1.0/orgs/%s/apiKeys/%s/whitelist"
23+
const whitelistAPIKeysPath = "api/atlas/v1.0/orgs/%s/apiKeys/%s/whitelist" //nolint:gosec // This is a path
2424

2525
// WhitelistAPIKeysService is an interface for interfacing with the Whitelist API Keys
2626
// endpoints of the MongoDB Atlas API.

0 commit comments

Comments
 (0)