Skip to content

Commit e938f34

Browse files
Merge branch 'main' into server-update-enablement
2 parents 560d63d + a44cfba commit e938f34

File tree

180 files changed

+3207
-3341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+3207
-3341
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- main
99

1010
env:
11-
GO_VERSION: "1.24"
11+
GO_VERSION: "1.26"
1212
CODE_COVERAGE_FILE_NAME: "coverage.out" # must be the same as in Makefile
1313
CODE_COVERAGE_ARTIFACT_NAME: "code-coverage"
1414

CONTRIBUTION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ If you want to onboard resources of a STACKIT service `foo` that was not yet in
103103

104104
### Local development
105105

106-
To test your changes locally, you have to compile the provider (requires Go 1.24) and configure the Terraform CLI to use the local version.
106+
To test your changes locally, you have to compile the provider (requires Go 1.26) and configure the Terraform CLI to use the local version.
107107

108108
1. Clone the repository.
109109
1. Run `$ make build` to build the Terraform provider binary in `<PATH_TO_REPO>/bin/`

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/stackitcloud/terraform-provider-stackit
22

3-
go 1.24.0
3+
go 1.26.0
44

55
require (
66
github.com/google/go-cmp v0.7.0

golang-ci.yaml

Lines changed: 87 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,111 @@
11
# This file contains all available configuration options
22
# with their default values.
33

4+
version: "2"
45
# options for analysis running
56
run:
67
# default concurrency is a available CPU number
78
concurrency: 4
89

910
# timeout for analysis, e.g. 30s, 5m, default is 1m
1011
timeout: 5m
11-
linters-settings:
12-
goimports:
13-
# put imports beginning with prefix after 3rd-party packages;
14-
# it's a comma-separated list of prefixes
15-
local-prefixes: github.com/freiheit-com/nmww
16-
depguard:
17-
rules:
18-
main:
19-
list-mode: lax # Everything is allowed unless it is denied
20-
deny:
21-
- pkg: "github.com/stretchr/testify"
22-
desc: Do not use a testing framework
23-
misspell:
24-
# Correct spellings using locale preferences for US or UK.
25-
# Default is to use a neutral variety of English.
26-
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
27-
locale: US
28-
golint:
29-
min-confidence: 0.8
30-
gosec:
31-
excludes:
32-
# Suppressions: (see https://github.com/securego/gosec#available-rules for details)
33-
- G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck
34-
- G102 # "Bind to all interfaces" -> since this is normal in k8s
35-
- G304 # "File path provided as taint input" -> too many false positives
36-
- G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close()
37-
nakedret:
38-
max-func-lines: 0
39-
revive:
40-
ignore-generated-header: true
41-
severity: error
42-
# https://github.com/mgechev/revive
43-
rules:
44-
- name: errorf
45-
- name: context-as-argument
46-
- name: error-return
47-
- name: increment-decrement
48-
- name: indent-error-flow
49-
- name: superfluous-else
50-
- name: unused-parameter
51-
- name: unreachable-code
52-
- name: atomic
53-
- name: empty-lines
54-
- name: early-return
55-
gocritic:
56-
enabled-tags:
57-
- performance
58-
- style
59-
- experimental
60-
disabled-checks:
61-
- wrapperFunc
62-
- typeDefFirst
63-
- ifElseChain
64-
- dupImport # https://github.com/go-critic/go-critic/issues/845
6512
linters:
6613
enable:
67-
# https://golangci-lint.run/usage/linters/
68-
# default linters
69-
- gosimple
70-
- govet
71-
- ineffassign
72-
- staticcheck
73-
- typecheck
74-
- unused
75-
# additional linters
14+
- bodyclose
15+
- depguard
7616
- errorlint
17+
- forcetypeassert
7718
- gochecknoinits
7819
- gocritic
79-
- gofmt
80-
- goimports
8120
- gosec
8221
- misspell
8322
- nakedret
8423
- revive
85-
- depguard
86-
- bodyclose
8724
- sqlclosecheck
8825
- wastedassign
89-
- forcetypeassert
90-
- errcheck
9126
disable:
9227
- noctx # false positive: finds errors with http.NewRequest that dont make sense
9328
- unparam # false positives
94-
issues:
95-
exclude-use-default: false
96-
# disable deprecation errors while we switch over to the SDK structure with multi API version support
97-
exclude-rules:
98-
- linters:
99-
- staticcheck
100-
text: "SA1019:"
29+
settings:
30+
depguard:
31+
rules:
32+
main:
33+
list-mode: lax # Everything is allowed unless it is denied
34+
deny:
35+
- pkg: github.com/stretchr/testify
36+
desc: Do not use a testing framework
37+
gocritic:
38+
disabled-checks:
39+
- wrapperFunc
40+
- typeDefFirst
41+
- ifElseChain
42+
- dupImport # https://github.com/go-critic/go-critic/issues/845
43+
enabled-tags:
44+
- performance
45+
- style
46+
- experimental
47+
gosec:
48+
excludes:
49+
# Suppressions: (see https://github.com/securego/gosec#available-rules for details)
50+
- G101 # "Look for hardcoded credentials" -> a lot of false positives in descriptions for resources like mariadb/credential
51+
- G104 # "Audit errors not checked" -> which we don't need and is a badly implemented version of errcheck
52+
- G102 # "Bind to all interfaces" -> since this is normal in k8s
53+
- G304 # "File path provided as taint input" -> too many false positives
54+
- G307 # "Deferring unsafe method "Close" on type "io.ReadCloser" -> false positive when calling defer resp.Body.Close()
55+
misspell:
56+
# Correct spellings using locale preferences for US or UK.
57+
# Default is to use a neutral variety of English.
58+
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
59+
locale: US
60+
nakedret:
61+
max-func-lines: 0
62+
revive:
63+
severity: error
64+
# https://github.com/mgechev/revive
65+
rules:
66+
- name: errorf
67+
- name: context-as-argument
68+
- name: error-return
69+
- name: increment-decrement
70+
- name: indent-error-flow
71+
- name: superfluous-else
72+
- name: unused-parameter
73+
- name: unreachable-code
74+
- name: atomic
75+
- name: empty-lines
76+
- name: early-return
77+
staticcheck:
78+
checks:
79+
# default from https://golangci-lint.run/docs/linters/configuration/#staticcheck
80+
- all
81+
- "-ST1000"
82+
- "-ST1003"
83+
- "-ST1016"
84+
- "-ST1020"
85+
- "-ST1021"
86+
- "-ST1022"
87+
# customizations
88+
- "-SA1019" # disable deprecation errors while we switch over to the SDK structure with multi API version support
89+
- "-QF1001" # disable 'could apply De Morgan's law': readability of boolean expressions is subjective and should be decided on a case-by-case basis
90+
- "-QF1012" # disable 'use fmt.Fprintf instead' Fprintf returns bytes written and an error, which we'd have to handle/ignore to appease some other linter
91+
exclusions:
92+
generated: lax
93+
rules:
94+
- linters:
95+
- gocritic
96+
text: 'dupOption'
97+
path: _acc_test\.go
98+
paths:
99+
- third_party$
100+
- builtin$
101+
- examples$
102+
formatters:
103+
enable:
104+
- gofmt
105+
- goimports
106+
exclusions:
107+
generated: lax
108+
paths:
109+
- third_party$
110+
- builtin$
111+
- examples$

scripts/project.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ elif [ "$action" = "tools" ]; then
1616

1717
go mod download
1818

19-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0
19+
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4
2020
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@v0.21.0
2121
else
2222
echo "Invalid action: '$action', please use $0 help for help"

stackit/internal/conversion/conversion.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ func ToTerraformStringMap(ctx context.Context, m map[string]string) (basetypes.M
6363
}
6464

6565
// ToStringInterfaceMap converts a basetypes.MapValue of Strings to a map[string]interface{}.
66-
func ToStringInterfaceMap(ctx context.Context, m basetypes.MapValue) (map[string]interface{}, error) {
66+
func ToStringInterfaceMap(ctx context.Context, m basetypes.MapValue) (map[string]any, error) {
6767
labels := map[string]string{}
6868
diags := m.ElementsAs(ctx, &labels, false)
6969
if diags.HasError() {
7070
return nil, fmt.Errorf("converting from MapValue: %w", core.DiagsToError(diags))
7171
}
7272

73-
interfaceMap := make(map[string]interface{}, len(labels))
73+
interfaceMap := make(map[string]any, len(labels))
7474
for k, v := range labels {
7575
interfaceMap[k] = v
7676
}
@@ -184,7 +184,7 @@ func StringSetToSlice(set basetypes.SetValue) ([]string, error) {
184184
// It takes a current map as it is in the terraform state and a desired map as it is in the user configuratiom
185185
// and builds a map which sets to null keys that should be removed, updates the values of existing keys and adds new keys
186186
// This method is needed because in partial updates, e.g. if the key is not provided it is ignored and not removed
187-
func ToJSONMapPartialUpdatePayload(ctx context.Context, current, desired types.Map) (map[string]interface{}, error) {
187+
func ToJSONMapPartialUpdatePayload(ctx context.Context, current, desired types.Map) (map[string]any, error) {
188188
currentMap, err := ToStringInterfaceMap(ctx, current)
189189
if err != nil {
190190
return nil, fmt.Errorf("converting to Go map: %w", err)
@@ -195,7 +195,7 @@ func ToJSONMapPartialUpdatePayload(ctx context.Context, current, desired types.M
195195
return nil, fmt.Errorf("converting to Go map: %w", err)
196196
}
197197

198-
mapPayload := map[string]interface{}{}
198+
mapPayload := map[string]any{}
199199
// Update and remove existing keys
200200
for k := range currentMap {
201201
if desiredValue, ok := desiredMap[k]; ok {

stackit/internal/conversion/conversion_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestFromTerraformStringMapToInterfaceMap(t *testing.T) {
2424
tests := []struct {
2525
name string
2626
args args
27-
want map[string]interface{}
27+
want map[string]any
2828
wantErr bool
2929
}{
3030
{
@@ -37,7 +37,7 @@ func TestFromTerraformStringMapToInterfaceMap(t *testing.T) {
3737
"key3": types.StringValue("value3"),
3838
}),
3939
},
40-
want: map[string]interface{}{
40+
want: map[string]any{
4141
"key": "value",
4242
"key2": "value2",
4343
"key3": "value3",
@@ -50,7 +50,7 @@ func TestFromTerraformStringMapToInterfaceMap(t *testing.T) {
5050
ctx: context.Background(),
5151
m: types.MapValueMust(types.StringType, map[string]attr.Value{}),
5252
},
53-
want: map[string]interface{}{},
53+
want: map[string]any{},
5454
wantErr: false,
5555
},
5656
{
@@ -59,7 +59,7 @@ func TestFromTerraformStringMapToInterfaceMap(t *testing.T) {
5959
ctx: context.Background(),
6060
m: types.MapNull(types.StringType),
6161
},
62-
want: map[string]interface{}{},
62+
want: map[string]any{},
6363
wantErr: false,
6464
},
6565
{
@@ -92,7 +92,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
9292
description string
9393
currentLabels types.Map
9494
desiredLabels types.Map
95-
expected map[string]interface{}
95+
expected map[string]any
9696
isValid bool
9797
}{
9898
{
@@ -103,7 +103,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
103103
types.MapValueMust(types.StringType, map[string]attr.Value{
104104
"key": types.StringValue("value"),
105105
}),
106-
map[string]interface{}{
106+
map[string]any{
107107
"key": "value",
108108
},
109109
true,
@@ -116,7 +116,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
116116
types.MapValueMust(types.StringType, map[string]attr.Value{
117117
"key": types.StringValue("updated_value"),
118118
}),
119-
map[string]interface{}{
119+
map[string]any{
120120
"key": "updated_value",
121121
},
122122
true,
@@ -130,7 +130,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
130130
types.MapValueMust(types.StringType, map[string]attr.Value{
131131
"key": types.StringValue("value"),
132132
}),
133-
map[string]interface{}{
133+
map[string]any{
134134
"key": "value",
135135
"key2": nil,
136136
},
@@ -145,7 +145,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
145145
"key": types.StringValue("value"),
146146
"key2": types.StringValue("value2"),
147147
}),
148-
map[string]interface{}{
148+
map[string]any{
149149
"key": "value",
150150
"key2": "value2",
151151
},
@@ -158,7 +158,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
158158
"key2": types.StringValue("value2"),
159159
}),
160160
types.MapValueMust(types.StringType, map[string]attr.Value{}),
161-
map[string]interface{}{
161+
map[string]any{
162162
"key": nil,
163163
"key2": nil,
164164
},
@@ -171,7 +171,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
171171
"key2": types.StringValue("value2"),
172172
}),
173173
types.MapNull(types.StringType),
174-
map[string]interface{}{
174+
map[string]any{
175175
"key": nil,
176176
"key2": nil,
177177
},
@@ -184,7 +184,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
184184
"key": types.StringValue("value"),
185185
"key2": types.StringValue("value2"),
186186
}),
187-
map[string]interface{}{
187+
map[string]any{
188188
"key": "value",
189189
"key2": "value2",
190190
},
@@ -197,7 +197,7 @@ func TestToJSONMapUpdatePayload(t *testing.T) {
197197
"key": types.StringValue("value"),
198198
"key2": types.StringValue("value2"),
199199
}),
200-
map[string]interface{}{
200+
map[string]any{
201201
"key": "value",
202202
"key2": "value2",
203203
},

stackit/internal/core/core.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func LogResponse(ctx context.Context) context.Context {
157157
traceId := runtime.GetTraceId(ctx)
158158
ctx = tflog.SetField(ctx, "x-trace-id", traceId)
159159

160-
tflog.Info(ctx, "response data", map[string]interface{}{
160+
tflog.Info(ctx, "response data", map[string]any{
161161
"x-trace-id": traceId,
162162
})
163163
return ctx

stackit/internal/services/access_token/ephemeral_resource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func startMockTokenServer() *httptest.Server {
3030
Scope: "mock_scope",
3131
}
3232
w.Header().Set("Content-Type", "application/json")
33-
_ = json.NewEncoder(w).Encode(resp)
33+
_ = json.NewEncoder(w).Encode(resp) // nolint:gosec // mock_access_token is not sensitive information
3434
})
3535
return httptest.NewServer(handler)
3636
}

0 commit comments

Comments
 (0)