Skip to content

Commit 4e18c72

Browse files
committed
Run modernize
1 parent 61e99c5 commit 4e18c72

File tree

22 files changed

+57
-73
lines changed

22 files changed

+57
-73
lines changed

internal/api/debug_middleware.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func debug(mux goahttp.Muxer, w io.Writer) func(http.Handler) http.Handler {
7777
}
7878
if len(b) > 0 {
7979
buf.WriteByte('\n')
80-
lines := strings.Split(string(b), "\n")
81-
for _, line := range lines {
80+
lines := strings.SplitSeq(string(b), "\n")
81+
for line := range lines {
8282
fmt.Fprintf(buf, "[%s] %s\n", reqID, line)
8383
}
8484
}
@@ -104,8 +104,8 @@ func debug(mux goahttp.Muxer, w io.Writer) func(http.Handler) http.Handler {
104104
}
105105
if printResponseBody {
106106
buf.WriteByte('\n')
107-
lines := strings.Split(dupper.Buffer.String(), "\n")
108-
for _, line := range lines {
107+
lines := strings.SplitSeq(dupper.Buffer.String(), "\n")
108+
for line := range lines {
109109
fmt.Fprintf(buf, "[%s] %s\n", reqID, line)
110110
}
111111
}

internal/api/design/pagination.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package design
22

33
import "goa.design/goa/v3/dsl"
44

5-
func PaginatedCollectionOf(v interface{}, adsl ...func()) interface{} {
5+
func PaginatedCollectionOf(v any, adsl ...func()) any {
66
return func() {
77
dsl.Attribute("items", dsl.CollectionOf(v, adsl...))
88
dsl.Attribute("next_cursor", dsl.String)

internal/api/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func loggerAdapter(logger logr.Logger) middleware.Logger {
1818
}
1919

2020
// Log implements middleware.Logger.
21-
func (a *adapter) Log(keyvals ...interface{}) error {
21+
func (a *adapter) Log(keyvals ...any) error {
2222
a.logger.Info("", keyvals...)
2323
return nil
2424
}

internal/bundler/metadata.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package bundler
33
import (
44
"encoding/csv"
55
"fmt"
6+
"maps"
67
"sort"
78

89
"github.com/spf13/afero"
@@ -29,9 +30,7 @@ func (m *MetadataSet) Entries() map[string][][2]string {
2930

3031
// Make a copy so the returned value won't race with future log requests.
3132
entries := make(map[string][][2]string)
32-
for k, v := range m.entries {
33-
entries[k] = v
34-
}
33+
maps.Copy(entries, m.entries)
3534
return entries
3635
}
3736

internal/collection/collection.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (svc *collectionImpl) Goa() goacollection.Service {
5959

6060
func (svc *collectionImpl) Create(ctx context.Context, col *Collection) error {
6161
query := `INSERT INTO collection (name, workflow_id, run_id, transfer_id, aip_id, original_id, pipeline_id, decision_token, status) VALUES ((?), (?), (?), (?), (?), (?), (?), (?), (?))`
62-
args := []interface{}{
62+
args := []any{
6363
col.Name,
6464
col.WorkflowID,
6565
col.RunID,
@@ -121,7 +121,7 @@ func (svc *collectionImpl) UpdateWorkflowStatus(ctx context.Context, ID uint, na
121121
}
122122

123123
query := `UPDATE collection SET name = (?), workflow_id = (?), run_id = (?), transfer_id = (?), aip_id = (?), pipeline_id = (?), status = (?), completed_at = (?) WHERE id = (?)`
124-
args := []interface{}{
124+
args := []any{
125125
name,
126126
workflowID,
127127
runID,
@@ -144,7 +144,7 @@ func (svc *collectionImpl) UpdateWorkflowStatus(ctx context.Context, ID uint, na
144144

145145
func (svc *collectionImpl) SetStatus(ctx context.Context, ID uint, status Status) error {
146146
query := `UPDATE collection SET status = (?) WHERE id = (?)`
147-
args := []interface{}{
147+
args := []any{
148148
status,
149149
ID,
150150
}
@@ -160,7 +160,7 @@ func (svc *collectionImpl) SetStatus(ctx context.Context, ID uint, status Status
160160

161161
func (svc *collectionImpl) SetStatusInProgress(ctx context.Context, ID uint, startedAt time.Time) error {
162162
var query string
163-
args := []interface{}{StatusInProgress}
163+
args := []any{StatusInProgress}
164164

165165
if !startedAt.IsZero() {
166166
query = `UPDATE collection SET status = (?), started_at = (?) WHERE id = (?)`
@@ -181,7 +181,7 @@ func (svc *collectionImpl) SetStatusInProgress(ctx context.Context, ID uint, sta
181181

182182
func (svc *collectionImpl) SetStatusPending(ctx context.Context, ID uint, taskToken []byte) error {
183183
query := `UPDATE collection SET status = (?), decision_token = (?) WHERE id = (?)`
184-
args := []interface{}{
184+
args := []any{
185185
StatusPending,
186186
taskToken,
187187
ID,
@@ -198,7 +198,7 @@ func (svc *collectionImpl) SetStatusPending(ctx context.Context, ID uint, taskTo
198198

199199
func (svc *collectionImpl) SetOriginalID(ctx context.Context, ID uint, originalID string) error {
200200
query := `UPDATE collection SET original_id = (?) WHERE id = (?)`
201-
args := []interface{}{
201+
args := []any{
202202
originalID,
203203
ID,
204204
}
@@ -212,7 +212,7 @@ func (svc *collectionImpl) SetOriginalID(ctx context.Context, ID uint, originalI
212212
return nil
213213
}
214214

215-
func (svc *collectionImpl) updateRow(ctx context.Context, query string, args []interface{}) (int64, error) {
215+
func (svc *collectionImpl) updateRow(ctx context.Context, query string, args []any) (int64, error) {
216216
query = svc.db.Rebind(query)
217217
res, err := svc.db.ExecContext(ctx, query, args...)
218218
if err != nil {
@@ -229,7 +229,7 @@ func (svc *collectionImpl) updateRow(ctx context.Context, query string, args []i
229229

230230
func (svc *collectionImpl) read(ctx context.Context, ID uint) (*Collection, error) {
231231
query := "SELECT id, name, workflow_id, run_id, transfer_id, aip_id, original_id, pipeline_id, decision_token, status, CONVERT_TZ(created_at, @@session.time_zone, '+00:00') AS created_at, CONVERT_TZ(started_at, @@session.time_zone, '+00:00') AS started_at, CONVERT_TZ(completed_at, @@session.time_zone, '+00:00') AS completed_at FROM collection WHERE id = (?)"
232-
args := []interface{}{ID}
232+
args := []any{ID}
233233
c := Collection{}
234234

235235
query = svc.db.Rebind(query)

internal/collection/goa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (w *goaWrapper) Monitor(ctx context.Context, stream goacollection.MonitorSe
8585
// List all stored collections. It implements goacollection.Service.
8686
func (w *goaWrapper) List(ctx context.Context, payload *goacollection.ListPayload) (*goacollection.ListResult, error) {
8787
query := "SELECT id, name, workflow_id, run_id, transfer_id, aip_id, original_id, pipeline_id, status, CONVERT_TZ(created_at, @@session.time_zone, '+00:00') AS created_at, CONVERT_TZ(started_at, @@session.time_zone, '+00:00') AS started_at, CONVERT_TZ(completed_at, @@session.time_zone, '+00:00') AS completed_at FROM collection"
88-
args := []interface{}{}
88+
args := []any{}
8989

9090
// We extract one extra item so we can tell the next cursor.
9191
const limit = 20

internal/collection/status_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func TestStatus(t *testing.T) {
4545
},
4646
}
4747
for _, tc := range tests {
48-
tc := tc
4948
t.Run(fmt.Sprintf("Status_%s", tc.str), func(t *testing.T) {
5049
s := NewStatus(tc.str)
5150
assert.Assert(t, s != StatusUnknown)

internal/metadata/transfer_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,10 @@ func TestFromTransferName(t *testing.T) {
6969
}
7070

7171
for _, tc := range tests {
72-
tc := tc
7372
t.Run(tc.transferName, func(t *testing.T) {
7473
t.Parallel()
7574

7675
assert.DeepEqual(t, metadata.FromTransferName(tc.transferName, tc.isDir), tc.expected)
7776
})
78-
7977
}
8078
}

internal/nha/activities/hari_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestHARIActivity(t *testing.T) {
4040

4141
// HARI hook configuration. If baseURL is defined, it overrides the
4242
// one provided by the test HTTP server.
43-
hariConfig map[string]interface{}
43+
hariConfig map[string]any
4444

4545
// Temporary directory options. Optional.
4646
dirOpts []fs.PathOp
@@ -65,7 +65,7 @@ func TestHARIActivity(t *testing.T) {
6565
Type: nha.TransferTypeDPJ,
6666
},
6767
},
68-
hariConfig: map[string]interface{}{},
68+
hariConfig: map[string]any{},
6969
dirOpts: []fs.PathOp{
7070
fs.WithDir("DPJ/journal"),
7171
// XML generated is a trimmed-down version, e.g. `pasientjournal` not included.
@@ -107,7 +107,7 @@ func TestHARIActivity(t *testing.T) {
107107
Type: nha.TransferTypeEPJ,
108108
},
109109
},
110-
hariConfig: map[string]interface{}{},
110+
hariConfig: map[string]any{},
111111
dirOpts: []fs.PathOp{
112112
fs.WithDir("EPJ/journal"),
113113
fs.WithFile("EPJ/journal/avlxml.xml", "<avlxml/>"),
@@ -139,7 +139,7 @@ func TestHARIActivity(t *testing.T) {
139139
Type: nha.TransferTypeAVLXML,
140140
},
141141
},
142-
hariConfig: map[string]interface{}{},
142+
hariConfig: map[string]any{},
143143
dirOpts: []fs.PathOp{
144144
fs.WithDir("AVLXML/objekter"),
145145
fs.WithFile(
@@ -166,7 +166,7 @@ func TestHARIActivity(t *testing.T) {
166166
Type: nha.TransferTypeAVLXML,
167167
},
168168
},
169-
hariConfig: map[string]interface{}{},
169+
hariConfig: map[string]any{},
170170
dirOpts: []fs.PathOp{
171171
fs.WithDir("AVLXML/objekter"),
172172
fs.WithFile(
@@ -193,7 +193,7 @@ func TestHARIActivity(t *testing.T) {
193193
Type: nha.TransferTypeOther,
194194
},
195195
},
196-
hariConfig: map[string]interface{}{},
196+
hariConfig: map[string]any{},
197197
dirOpts: []fs.PathOp{
198198
fs.WithDir("OTHER/journal"),
199199
fs.WithFile("OTHER/journal/avlxml.xml", "<avlxml/>"),
@@ -225,7 +225,7 @@ func TestHARIActivity(t *testing.T) {
225225
Type: nha.TransferTypeDPJ,
226226
},
227227
},
228-
hariConfig: map[string]interface{}{},
228+
hariConfig: map[string]any{},
229229
dirOpts: []fs.PathOp{
230230
fs.WithDir("DPJ/Journal"),
231231
fs.WithFile("DPJ/Journal/avlxml.xml", "<avlxml/>"),
@@ -257,7 +257,7 @@ func TestHARIActivity(t *testing.T) {
257257
Type: nha.TransferTypeDPJ,
258258
},
259259
},
260-
hariConfig: map[string]interface{}{},
260+
hariConfig: map[string]any{},
261261
dirOpts: []fs.PathOp{
262262
fs.WithDir("DPJ/journal"),
263263
fs.WithFile("DPJ/journal/avlxml.xml", "<avlxml/>"),
@@ -289,7 +289,7 @@ func TestHARIActivity(t *testing.T) {
289289
Type: nha.TransferTypeDPJ,
290290
},
291291
},
292-
hariConfig: map[string]interface{}{"mock": true},
292+
hariConfig: map[string]any{"mock": true},
293293
dirOpts: []fs.PathOp{
294294
fs.WithDir("DPJ/journal"),
295295
fs.WithFile("DPJ/journal/avlxml.xml", "<avlxml/>"),
@@ -313,7 +313,7 @@ func TestHARIActivity(t *testing.T) {
313313
Type: nha.TransferTypeDPJ,
314314
},
315315
},
316-
hariConfig: map[string]interface{}{},
316+
hariConfig: map[string]any{},
317317
dirOpts: []fs.PathOp{
318318
fs.WithDir("DPJ/journal"),
319319
fs.WithFile("DPJ/journal/avlxml.xml", "<avlxml/>"),
@@ -331,7 +331,7 @@ func TestHARIActivity(t *testing.T) {
331331
Type: nha.TransferTypeDPJ,
332332
},
333333
},
334-
hariConfig: map[string]interface{}{},
334+
hariConfig: map[string]any{},
335335
dirOpts: []fs.PathOp{
336336
fs.WithDir("DPJ/journal"),
337337
fs.WithFile("DPJ/journal/avlxml.xml", "<avlxml/>"),
@@ -357,7 +357,7 @@ func TestHARIActivity(t *testing.T) {
357357
Type: nha.TransferTypeDPJ,
358358
},
359359
},
360-
hariConfig: map[string]interface{}{},
360+
hariConfig: map[string]any{},
361361
dirOpts: []fs.PathOp{
362362
fs.WithDir("DPJ/journal"),
363363
fs.WithFile("DPJ/journal/avlxml.xml", "<avlxml/>"),
@@ -390,7 +390,7 @@ func TestHARIActivity(t *testing.T) {
390390
Type: nha.TransferTypeDPJ,
391391
},
392392
},
393-
hariConfig: map[string]interface{}{"baseurl": "http://192.168.1.50:12345"},
393+
hariConfig: map[string]any{"baseurl": "http://192.168.1.50:12345"},
394394
dirOpts: []fs.PathOp{
395395
fs.WithDir("DPJ/journal"),
396396
fs.WithFile("DPJ/journal/_____other_name_____.xml", "<avlxml/>"),
@@ -407,7 +407,7 @@ func TestHARIActivity(t *testing.T) {
407407
Type: nha.TransferTypeDPJ,
408408
},
409409
},
410-
hariConfig: map[string]interface{}{"baseurl": string([]byte{0x7f})},
410+
hariConfig: map[string]any{"baseurl": string([]byte{0x7f})},
411411
dirOpts: []fs.PathOp{
412412
fs.WithDir("DPJ/journal"),
413413
fs.WithFile("DPJ/journal/avlxml.xml", "<avlxml/>"),
@@ -492,11 +492,11 @@ func testError(t *testing.T, err error, wantErr string, wantNonRetryable bool) {
492492
}
493493
}
494494

495-
func createHariActivity(t *testing.T, hariConfig map[string]interface{}) *UpdateHARIActivity {
495+
func createHariActivity(t *testing.T, hariConfig map[string]any) *UpdateHARIActivity {
496496
t.Helper()
497497

498498
hooks := hooks.NewHooks(
499-
map[string]map[string]interface{}{
499+
map[string]map[string]any{
500500
"hari": hariConfig,
501501
},
502502
)
@@ -525,7 +525,7 @@ func TestHARIURL(t *testing.T) {
525525
},
526526
}
527527
for _, tc := range tests {
528-
act := createHariActivity(t, map[string]interface{}{
528+
act := createHariActivity(t, map[string]any{
529529
"baseurl": tc.baseURL,
530530
})
531531

internal/nha/activities/prod_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestProdActivity(t *testing.T) {
2323

2424
tests := map[string]struct {
2525
params UpdateProductionSystemActivityParams
26-
hookConfig *map[string]interface{}
26+
hookConfig *map[string]any
2727
dirOpts []fs.PathOp
2828
wantContent string
2929
wantNonRetryableError bool
@@ -91,7 +91,7 @@ func TestProdActivity(t *testing.T) {
9191
Type: nha.TransferTypeDPJ,
9292
},
9393
},
94-
hookConfig: &map[string]interface{}{},
94+
hookConfig: &map[string]any{},
9595
wantErr: "error looking up receiptPath configuration attribute: error accessing \"prod:receiptPath\"",
9696
wantNonRetryableError: true,
9797
},
@@ -104,7 +104,7 @@ func TestProdActivity(t *testing.T) {
104104
Type: nha.TransferTypeDPJ,
105105
},
106106
},
107-
hookConfig: &map[string]interface{}{
107+
hookConfig: &map[string]any{
108108
"receiptpath": tmpdir,
109109
},
110110
wantErr: "error creating receipt file",
@@ -123,7 +123,7 @@ func TestProdActivity(t *testing.T) {
123123

124124
tmpdir := fs.NewDir(t, "enduro")
125125
defer tmpdir.Remove()
126-
hookConfig := map[string]interface{}{"receiptpath": tmpdir.Path()}
126+
hookConfig := map[string]any{"receiptpath": tmpdir.Path()}
127127
if tc.hookConfig != nil {
128128
hookConfig = *tc.hookConfig
129129
}
@@ -152,11 +152,11 @@ func TestProdActivity(t *testing.T) {
152152
}
153153
}
154154

155-
func createProdActivity(t *testing.T, hookConfig map[string]interface{}) *UpdateProductionSystemActivity {
155+
func createProdActivity(t *testing.T, hookConfig map[string]any) *UpdateProductionSystemActivity {
156156
t.Helper()
157157

158158
hooks := hooks.NewHooks(
159-
map[string]map[string]interface{}{
159+
map[string]map[string]any{
160160
"prod": hookConfig,
161161
},
162162
)

0 commit comments

Comments
 (0)