diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0a338059..ebbbcd1c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,7 +3,7 @@ name: CI Workflow on: [pull_request, workflow_dispatch] env: - GO_VERSION: "1.22" + GO_VERSION: "1.23" jobs: main: diff --git a/go.mod b/go.mod index a9f01e4e..1bbca7a6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/stackitcloud/terraform-provider-stackit -go 1.22 +go 1.23 require ( github.com/google/go-cmp v0.6.0 diff --git a/golang-ci.yaml b/golang-ci.yaml index 7eceed18..3487f745 100644 --- a/golang-ci.yaml +++ b/golang-ci.yaml @@ -14,13 +14,12 @@ linters-settings: # it's a comma-separated list of prefixes local-prefixes: github.com/freiheit-com/nmww depguard: - list-type: blacklist - include-go-root: false - packages: - - github.com/stretchr/testify - packages-with-error-message: - # specify an error message to output when a blacklisted package is used - - github.com/stretchr/testify: "do not use a testing framework" + rules: + main: + list-mode: lax # Everything is allowed unless it is denied + deny: + - pkg: "github.com/stretchr/testify" + desc: Do not use a testing framework misspell: # Correct spellings using locale preferences for US or UK. # Default is to use a neutral variety of English. @@ -75,7 +74,6 @@ linters: - unused # additional linters - errorlint - - exportloopref - gochecknoinits - gocritic - gofmt @@ -91,9 +89,6 @@ linters: - forcetypeassert - errcheck disable: - - structcheck # deprecated - - deadcode # deprecated - - varcheck # deprecated - noctx # false positive: finds errors with http.NewRequest that dont make sense - unparam # false positives issues: diff --git a/scripts/project.sh b/scripts/project.sh index c5da2929..f2f404ba 100755 --- a/scripts/project.sh +++ b/scripts/project.sh @@ -16,7 +16,7 @@ elif [ "$action" = "tools" ]; then go mod download - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0 go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.16.0 else echo "Invalid action: '$action', please use $0 help for help" diff --git a/stackit/internal/services/iaas/networkarea/resource_test.go b/stackit/internal/services/iaas/networkarea/resource_test.go index 81320270..a1e6d87b 100644 --- a/stackit/internal/services/iaas/networkarea/resource_test.go +++ b/stackit/internal/services/iaas/networkarea/resource_test.go @@ -854,7 +854,7 @@ func TestUpdateNetworkRanges(t *testing.T) { networkRangesStates["pr-3"] = true // Handler for getting all network ranges - getAllNetworkRangesHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + getAllNetworkRangesHandler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") if tt.getAllNetworkRangesFails { w.WriteHeader(http.StatusInternalServerError) diff --git a/stackit/internal/services/objectstorage/credential/resource_test.go b/stackit/internal/services/objectstorage/credential/resource_test.go index 54c9cb0c..9cf8bfc2 100644 --- a/stackit/internal/services/objectstorage/credential/resource_test.go +++ b/stackit/internal/services/objectstorage/credential/resource_test.go @@ -381,7 +381,7 @@ func TestReadCredentials(t *testing.T) { t.Fatalf("Failed to marshal mocked response: %v", err) } - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + handler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") if tt.getCredentialsFails { w.WriteHeader(http.StatusBadGateway) diff --git a/stackit/internal/services/secretsmanager/instance/resource_test.go b/stackit/internal/services/secretsmanager/instance/resource_test.go index ba1e9e3e..39d2df83 100644 --- a/stackit/internal/services/secretsmanager/instance/resource_test.go +++ b/stackit/internal/services/secretsmanager/instance/resource_test.go @@ -345,7 +345,7 @@ func TestUpdateACLs(t *testing.T) { aclsStates["acl-3"] = true // Handler for getting all ACLs - getAllACLsHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + getAllACLsHandler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") if tt.getAllACLsFails { w.WriteHeader(http.StatusInternalServerError) diff --git a/stackit/internal/services/ske/cluster/resource.go b/stackit/internal/services/ske/cluster/resource.go index 80ff6a74..9d578f5e 100644 --- a/stackit/internal/services/ske/cluster/resource.go +++ b/stackit/internal/services/ske/cluster/resource.go @@ -353,7 +353,7 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re Optional: true, DeprecationMessage: "Use `kubernetes_version_min instead`. Setting a specific kubernetes version would cause errors during minor version upgrades due to forced updates. In those cases, this field might not represent the actual kubernetes version used in the cluster.", PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIf(stringplanmodifier.RequiresReplaceIfFunc(func(ctx context.Context, sr planmodifier.StringRequest, rrifr *stringplanmodifier.RequiresReplaceIfFuncResponse) { + stringplanmodifier.RequiresReplaceIf(stringplanmodifier.RequiresReplaceIfFunc(func(_ context.Context, sr planmodifier.StringRequest, rrifr *stringplanmodifier.RequiresReplaceIfFuncResponse) { if sr.StateValue.IsNull() || sr.PlanValue.IsNull() { return } diff --git a/stackit/internal/validate/validate.go b/stackit/internal/validate/validate.go index 8b6ec78e..3633c6b5 100644 --- a/stackit/internal/validate/validate.go +++ b/stackit/internal/validate/validate.go @@ -54,7 +54,7 @@ func UUID() *Validator { return &Validator{ description: description, - validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { if _, err := uuid.Parse(req.ConfigValue.ValueString()); err != nil { resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic( req.Path, @@ -71,7 +71,7 @@ func IP() *Validator { return &Validator{ description: description, - validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { if net.ParseIP(req.ConfigValue.ValueString()) == nil { resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic( req.Path, @@ -127,7 +127,7 @@ func NoSeparator() *Validator { return &Validator{ description: description, - validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { if strings.Contains(req.ConfigValue.ValueString(), core.Separator) { resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic( req.Path, @@ -144,7 +144,7 @@ func NonLegacyProjectRole() *Validator { return &Validator{ description: description, - validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { if utils.IsLegacyProjectRole(req.ConfigValue.ValueString()) { resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic( req.Path, @@ -161,7 +161,7 @@ func MinorVersionNumber() *Validator { return &Validator{ description: description, - validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { exp := MajorMinorVersionRegex r := regexp.MustCompile(exp) version := req.ConfigValue.ValueString() @@ -181,7 +181,7 @@ func VersionNumber() *Validator { return &Validator{ description: description, - validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { minorVersionExp := MajorMinorVersionRegex minorVersionRegex := regexp.MustCompile(minorVersionExp) @@ -205,7 +205,7 @@ func RFC3339SecondsOnly() *Validator { return &Validator{ description: description, - validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { t, err := time.Parse(time.RFC3339, req.ConfigValue.ValueString()) if err != nil { resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic( @@ -233,7 +233,7 @@ func CIDR() *Validator { return &Validator{ description: description, - validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { _, _, err := net.ParseCIDR(req.ConfigValue.ValueString()) if err != nil { resp.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic( @@ -251,7 +251,7 @@ func Rrule() *Validator { return &Validator{ description: description, - validate: func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + validate: func(_ context.Context, req validator.StringRequest, resp *validator.StringResponse) { // The go library rrule-go expects \n before RRULE (to be a newline and not a space) // for example: "DTSTART;TZID=America/New_York:19970902T090000\nRRULE:FREQ=DAILY;COUNT=10" // whereas a valid rrule according to the API docs is: