Skip to content

Bump golangci/golangci-lint-action from 6.1.1 to 8.0.0 #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- run: go mod download
- run: go build -v .
- name: Run linters
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
version: latest

Expand Down
6 changes: 1 addition & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
# Visit https://golangci-lint.run/ for usage documentation
# and information on other useful linters
version: "2"
issues:
max-per-linter: 0
max-same-issues: 0

linters:
disable-all: true
enable:
- durationcheck
- errcheck
- copyloopvar
- forcetypeassert
- godot
- gofmt
- gosimple
- ineffassign
- makezero
- misspell
- nilerr
- predeclared
- staticcheck
- tenv
- unconvert
- unparam
- unused
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/hypercore_vm_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ func ShutdownVM(ctx context.Context, vmUUID string, restClient *utils.RestClient
return err
}
}
var maxWaitTime int = 300
var maxWaitTime = 300
envMaxWaitTime := os.Getenv("HC_VM_SHUTDOWN_TIMEOUT")
if envMaxWaitTime != "" {
val, err := strconv.Atoi(envMaxWaitTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ func SendHTTPRequest(client *http.Client, method string, url string, data []byte
if err != nil {
log.Fatalf("Sending request failed with %v", err)
}
defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
err = fmt.Errorf("there was an issue closing response body with: %w", cerr)
}
}()

// Read and print the response
body, err := io.ReadAll(resp.Body)
Expand Down
14 changes: 11 additions & 3 deletions internal/utils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ func ReadLocalFileBinary(filePath string) ([]byte, error) {
if err != nil {
return nil, fmt.Errorf("error opening file '%s': %s", filePath, err)
}
defer file.Close()
defer func() {
if cerr := file.Close(); cerr != nil && err == nil {
err = fmt.Errorf("error closing file '%s': %w", filePath, cerr)
}
}()

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

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

func RecoverDiagnostics(ctx context.Context, diags *diag.Diagnostics) {
if r := recover(); r != nil {
err := fmt.Errorf("Terraform provider got an unexpected error during execution: %v", r)
err := fmt.Errorf("terraform provider got an unexpected error during execution: %v", r)
*diags = append(*diags, diag.NewErrorDiagnostic("Unexpected error", err.Error()))
}
}
63 changes: 53 additions & 10 deletions internal/utils/rest_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ func (rc *RestClient) Login() {
if err != nil {
panic(fmt.Errorf("couldn't authenticate: %s", err.Error()))
}
defer resp.Body.Close()
defer func() {
if cerr := resp.Body.Close(); cerr != nil {
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
}
}()

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

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

Expand Down Expand Up @@ -289,7 +297,12 @@ func (rc *RestClient) CreateRecord(endpoint string, payload map[string]any, time
if err != nil {
return nil, resp.StatusCode, err
}
defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
}
}()

respJson := rc.ToJson(resp)
if resp.StatusCode == 400 {
Expand Down Expand Up @@ -336,7 +349,12 @@ func (rc *RestClient) CreateRecordWithList(endpoint string, payload []map[string
if err != nil {
return nil, resp.StatusCode, err
}
defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
}
}()

respJson := rc.ToJson(resp)
if resp.StatusCode == 400 {
Expand Down Expand Up @@ -374,7 +392,12 @@ func (rc *RestClient) UpdateRecord(endpoint string, payload map[string]any, time
if err != nil {
panic(fmt.Errorf("error making a request: %s", err.Error()))
}
defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
}
}()

respJson := rc.ToJson(resp)
if resp.StatusCode == 400 {
Expand Down Expand Up @@ -412,7 +435,12 @@ func (rc *RestClient) PutRecord(endpoint string, payload map[string]any, timeout
if err != nil {
panic(fmt.Errorf("error making a request: %s", err.Error()))
}
defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
}
}()

respJson := rc.ToJson(resp)
if resp.StatusCode == 400 {
Expand Down Expand Up @@ -451,7 +479,12 @@ func (rc *RestClient) PutBinaryRecord(endpoint string, binaryData []byte, conten
if err != nil {
panic(fmt.Errorf("error making a request: %s", err.Error()))
}
defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
}
}()

respJson := rc.ToJson(resp)
if resp.StatusCode == 400 {
Expand Down Expand Up @@ -490,7 +523,12 @@ func (rc *RestClient) PutBinaryRecordWithoutTaskTag(endpoint string, binaryData
if err != nil {
panic(fmt.Errorf("error making a request: %s", err.Error()))
}
defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
}
}()

if resp.StatusCode != 200 {
panic(fmt.Errorf("error making a request: got response status code %v", resp.StatusCode))
Expand Down Expand Up @@ -518,7 +556,12 @@ func (rc *RestClient) DeleteRecord(endpoint string, timeout float64, ctx context
if err != nil {
panic(fmt.Errorf("error making a request: %s", err.Error()))
}
defer resp.Body.Close()

defer func() {
if cerr := resp.Body.Close(); cerr != nil {
panic(fmt.Errorf("couldn't close response body: %s", cerr.Error()))
}
}()

respJson := rc.ToJson(resp)

Expand Down
2 changes: 1 addition & 1 deletion internal/utils/task_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (tt *TaskTag) WaitTask(restClient RestClient, ctx context.Context) {
panic(fmt.Sprintf("Error executing task: %s, %s", state, taskStatus))
}

if !(state == "RUNNING" || state == "QUEUED") { // TaskTag has finished
if state != "RUNNING" && state != "QUEUED" { // TaskTag has finished
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ func GetOneVM(uuid string, restClient RestClient) map[string]any {
}
if len(records) > 1 {
// uuid == ""
panic(fmt.Errorf("Multiple VMs found: uuid=%v", uuid))
panic(fmt.Errorf("multiple VMs found: uuid=%v", uuid))
}

return records[0]
Expand Down
Loading