Skip to content

Commit a7d9a9f

Browse files
Merge pull request #42 from ScaleComputing/dependabot/github_actions/golangci/golangci-lint-action-8.0.0
Bump golangci/golangci-lint-action from 6.1.1 to 8.0.0
2 parents 241a6b2 + 6fac5ca commit a7d9a9f

File tree

8 files changed

+75
-23
lines changed

8 files changed

+75
-23
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- run: go mod download
2828
- run: go build -v .
2929
- name: Run linters
30-
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
30+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
3131
with:
3232
version: latest
3333

.golangci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
# Visit https://golangci-lint.run/ for usage documentation
22
# and information on other useful linters
3+
version: "2"
34
issues:
4-
max-per-linter: 0
55
max-same-issues: 0
66

77
linters:
8-
disable-all: true
98
enable:
109
- durationcheck
1110
- errcheck
1211
- copyloopvar
1312
- forcetypeassert
1413
- godot
15-
- gofmt
16-
- gosimple
1714
- ineffassign
1815
- makezero
1916
- misspell
2017
- nilerr
2118
- predeclared
2219
- staticcheck
23-
- tenv
2420
- unconvert
2521
- unparam
2622
- unused

internal/provider/hypercore_vm_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ func ShutdownVM(ctx context.Context, vmUUID string, restClient *utils.RestClient
640640
return err
641641
}
642642
}
643-
var maxWaitTime int = 300
643+
var maxWaitTime = 300
644644
envMaxWaitTime := os.Getenv("HC_VM_SHUTDOWN_TIMEOUT")
645645
if envMaxWaitTime != "" {
646646
val, err := strconv.Atoi(envMaxWaitTime)

internal/provider/tests/acceptance/setup/acceptance_test_env_prepare.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ func SendHTTPRequest(client *http.Client, method string, url string, data []byte
8080
if err != nil {
8181
log.Fatalf("Sending request failed with %v", err)
8282
}
83-
defer resp.Body.Close()
83+
84+
defer func() {
85+
if cerr := resp.Body.Close(); cerr != nil {
86+
err = fmt.Errorf("there was an issue closing response body with: %w", cerr)
87+
}
88+
}()
8489

8590
// Read and print the response
8691
body, err := io.ReadAll(resp.Body)

internal/utils/helper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ func ReadLocalFileBinary(filePath string) ([]byte, error) {
238238
if err != nil {
239239
return nil, fmt.Errorf("error opening file '%s': %s", filePath, err)
240240
}
241-
defer file.Close()
241+
defer func() {
242+
if cerr := file.Close(); cerr != nil && err == nil {
243+
err = fmt.Errorf("error closing file '%s': %w", filePath, cerr)
244+
}
245+
}()
242246

243247
reader := bufio.NewReader(file)
244248
buffer := make([]byte, 4096) // 4KiB buffer
@@ -262,7 +266,11 @@ func FetchFileBinaryFromURL(url string) ([]byte, error) {
262266
if err != nil {
263267
return nil, err
264268
}
265-
defer resp.Body.Close()
269+
defer func() {
270+
if cerr := resp.Body.Close(); cerr != nil {
271+
err = fmt.Errorf("there was an issue closing response body with: %w", cerr)
272+
}
273+
}()
266274

267275
var binaryData []byte
268276
buffer := make([]byte, 4096) // 4 KiB buffer
@@ -334,7 +342,7 @@ func ValidateHTTP(httpUri string, path string) diag.Diagnostic {
334342

335343
func RecoverDiagnostics(ctx context.Context, diags *diag.Diagnostics) {
336344
if r := recover(); r != nil {
337-
err := fmt.Errorf("Terraform provider got an unexpected error during execution: %v", r)
345+
err := fmt.Errorf("terraform provider got an unexpected error during execution: %v", r)
338346
*diags = append(*diags, diag.NewErrorDiagnostic("Unexpected error", err.Error()))
339347
}
340348
}

internal/utils/rest_client.go

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ func (rc *RestClient) Login() {
201201
if err != nil {
202202
panic(fmt.Errorf("couldn't authenticate: %s", err.Error()))
203203
}
204-
defer resp.Body.Close()
204+
defer func() {
205+
if cerr := resp.Body.Close(); cerr != nil {
206+
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
207+
}
208+
}()
205209

206210
if resp.StatusCode != http.StatusOK {
207211
respBytes, _ := io.ReadAll(resp.Body)
@@ -237,9 +241,13 @@ func (rc *RestClient) ListRecords(endpoint string, query map[string]any, timeout
237241
if err != nil {
238242
panic(fmt.Errorf("error making a request: %s", err.Error()))
239243
}
240-
defer resp.Body.Close()
244+
defer func() {
245+
if cerr := resp.Body.Close(); cerr != nil {
246+
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
247+
}
248+
}()
241249

242-
if !(resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusNoContent) {
250+
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
243251
panic(fmt.Errorf("unexpected response: %d - %v", resp.StatusCode, rc.ToString(resp)))
244252
}
245253

@@ -289,7 +297,12 @@ func (rc *RestClient) CreateRecord(endpoint string, payload map[string]any, time
289297
if err != nil {
290298
return nil, resp.StatusCode, err
291299
}
292-
defer resp.Body.Close()
300+
301+
defer func() {
302+
if cerr := resp.Body.Close(); cerr != nil {
303+
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
304+
}
305+
}()
293306

294307
respJson := rc.ToJson(resp)
295308
if resp.StatusCode == 400 {
@@ -336,7 +349,12 @@ func (rc *RestClient) CreateRecordWithList(endpoint string, payload []map[string
336349
if err != nil {
337350
return nil, resp.StatusCode, err
338351
}
339-
defer resp.Body.Close()
352+
353+
defer func() {
354+
if cerr := resp.Body.Close(); cerr != nil {
355+
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
356+
}
357+
}()
340358

341359
respJson := rc.ToJson(resp)
342360
if resp.StatusCode == 400 {
@@ -374,7 +392,12 @@ func (rc *RestClient) UpdateRecord(endpoint string, payload map[string]any, time
374392
if err != nil {
375393
panic(fmt.Errorf("error making a request: %s", err.Error()))
376394
}
377-
defer resp.Body.Close()
395+
396+
defer func() {
397+
if cerr := resp.Body.Close(); cerr != nil {
398+
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
399+
}
400+
}()
378401

379402
respJson := rc.ToJson(resp)
380403
if resp.StatusCode == 400 {
@@ -412,7 +435,12 @@ func (rc *RestClient) PutRecord(endpoint string, payload map[string]any, timeout
412435
if err != nil {
413436
panic(fmt.Errorf("error making a request: %s", err.Error()))
414437
}
415-
defer resp.Body.Close()
438+
439+
defer func() {
440+
if cerr := resp.Body.Close(); cerr != nil {
441+
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
442+
}
443+
}()
416444

417445
respJson := rc.ToJson(resp)
418446
if resp.StatusCode == 400 {
@@ -451,7 +479,12 @@ func (rc *RestClient) PutBinaryRecord(endpoint string, binaryData []byte, conten
451479
if err != nil {
452480
panic(fmt.Errorf("error making a request: %s", err.Error()))
453481
}
454-
defer resp.Body.Close()
482+
483+
defer func() {
484+
if cerr := resp.Body.Close(); cerr != nil {
485+
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
486+
}
487+
}()
455488

456489
respJson := rc.ToJson(resp)
457490
if resp.StatusCode == 400 {
@@ -490,7 +523,12 @@ func (rc *RestClient) PutBinaryRecordWithoutTaskTag(endpoint string, binaryData
490523
if err != nil {
491524
panic(fmt.Errorf("error making a request: %s", err.Error()))
492525
}
493-
defer resp.Body.Close()
526+
527+
defer func() {
528+
if cerr := resp.Body.Close(); cerr != nil {
529+
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
530+
}
531+
}()
494532

495533
if resp.StatusCode != 200 {
496534
panic(fmt.Errorf("error making a request: got response status code %v", resp.StatusCode))
@@ -518,7 +556,12 @@ func (rc *RestClient) DeleteRecord(endpoint string, timeout float64, ctx context
518556
if err != nil {
519557
panic(fmt.Errorf("error making a request: %s", err.Error()))
520558
}
521-
defer resp.Body.Close()
559+
560+
defer func() {
561+
if cerr := resp.Body.Close(); cerr != nil {
562+
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
563+
}
564+
}()
522565

523566
respJson := rc.ToJson(resp)
524567

internal/utils/task_tag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (tt *TaskTag) WaitTask(restClient RestClient, ctx context.Context) {
6060
panic(fmt.Sprintf("Error executing task: %s, %s", state, taskStatus))
6161
}
6262

63-
if !(state == "RUNNING" || state == "QUEUED") { // TaskTag has finished
63+
if state != "RUNNING" && state != "QUEUED" { // TaskTag has finished
6464
return
6565
}
6666
}

internal/utils/vm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ func GetOneVM(uuid string, restClient RestClient) map[string]any {
626626
}
627627
if len(records) > 1 {
628628
// uuid == ""
629-
panic(fmt.Errorf("Multiple VMs found: uuid=%v", uuid))
629+
panic(fmt.Errorf("multiple VMs found: uuid=%v", uuid))
630630
}
631631

632632
return records[0]

0 commit comments

Comments
 (0)