Skip to content

Commit

Permalink
feat: Update golangci-lint version to 1.62.0 and go version to 1.23
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Dahmen <[email protected]>
  • Loading branch information
Fyusel committed Nov 26, 2024
1 parent 1051995 commit 3a378c7
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI Workflow
on: [pull_request, workflow_dispatch]

env:
GO_VERSION: "1.22"
GO_VERSION: "1.23"

jobs:
main:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 6 additions & 11 deletions golang-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -75,7 +74,6 @@ linters:
- unused
# additional linters
- errorlint
- exportloopref
- gochecknoinits
- gocritic
- gofmt
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
else
echo "Invalid action: '$action', please use $0 help for help"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion stackit/internal/services/ske/cluster/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
18 changes: 9 additions & 9 deletions stackit/internal/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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()
Expand All @@ -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)

Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand Down

0 comments on commit 3a378c7

Please sign in to comment.