Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit 91c803e

Browse files
authored
Merge pull request #2475 from thedadams/add-revive-lint
chore: add revive lint and fix related issues
2 parents e5c17fb + 6cc288a commit 91c803e

File tree

164 files changed

+621
-650
lines changed

Some content is hidden

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

164 files changed

+621
-650
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ linters:
2121
- unused
2222
- goimports
2323
- whitespace
24+
- revive
2425
fast: false
2526
max-same-issues: 50

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ setup-ci-image:
2525
docker build -t acorn:v-ci .
2626
docker save acorn:v-ci | docker exec -i $$(docker ps | grep k3s | awk '{print $$1}') ctr --address /run/k3s/containerd/containerd.sock images import -
2727

28-
GOLANGCI_LINT_VERSION ?= v1.54.2
28+
GOLANGCI_LINT_VERSION ?= v1.55.2
2929
setup-env:
3030
if ! command -v golangci-lint &> /dev/null; then \
3131
echo "Could not find golangci-lint, installing version $(GOLANGCI_LINT_VERSION)."; \

integration/client/apps/apps_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ func TestAppLog(t *testing.T) {
411411
assert.NotEqual(t, "", msg1.Line)
412412

413413
go func() {
414+
//nolint:revive
414415
for range msgs {
415416
}
416417
}()

integration/client/credentials/credentials_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ func TestCredentialCreate(t *testing.T) {
1414
helper.StartController(t)
1515
restConfig := helper.StartAPI(t)
1616

17-
reg, close := helper.StartRegistry(t)
18-
reg1, close1 := helper.StartRegistry(t)
19-
defer close()
20-
defer close1()
17+
reg, cancel := helper.StartRegistry(t)
18+
reg1, cancel1 := helper.StartRegistry(t)
19+
defer cancel()
20+
defer cancel1()
2121

2222
ctx := helper.GetCTX(t)
2323
kclient := helper.MustReturn(kclient.Default)
@@ -60,10 +60,10 @@ func TestCredentialList(t *testing.T) {
6060
helper.StartController(t)
6161
restConfig := helper.StartAPI(t)
6262

63-
reg, close := helper.StartRegistry(t)
64-
reg1, close1 := helper.StartRegistry(t)
65-
defer close()
66-
defer close1()
63+
reg, cancel := helper.StartRegistry(t)
64+
reg1, cancel1 := helper.StartRegistry(t)
65+
defer cancel()
66+
defer cancel1()
6767

6868
ctx := helper.GetCTX(t)
6969
kclient := helper.MustReturn(kclient.Default)
@@ -110,10 +110,10 @@ func TestCredentialGet(t *testing.T) {
110110
helper.StartController(t)
111111
restConfig := helper.StartAPI(t)
112112

113-
reg, close := helper.StartRegistry(t)
114-
reg1, close1 := helper.StartRegistry(t)
115-
defer close()
116-
defer close1()
113+
reg, cancel := helper.StartRegistry(t)
114+
reg1, cancel1 := helper.StartRegistry(t)
115+
defer cancel()
116+
defer cancel1()
117117

118118
ctx := helper.GetCTX(t)
119119
kclient := helper.MustReturn(kclient.Default)
@@ -146,10 +146,10 @@ func TestCredentialUpdate(t *testing.T) {
146146
helper.StartController(t)
147147
restConfig := helper.StartAPI(t)
148148

149-
reg, close := helper.StartRegistry(t)
150-
reg1, close1 := helper.StartRegistry(t)
151-
defer close()
152-
defer close1()
149+
reg, cancel := helper.StartRegistry(t)
150+
reg1, cancel1 := helper.StartRegistry(t)
151+
defer cancel()
152+
defer cancel1()
153153

154154
ctx := helper.GetCTX(t)
155155
kclient := helper.MustReturn(kclient.Default)
@@ -189,10 +189,10 @@ func TestCredentialDelete(t *testing.T) {
189189
helper.StartController(t)
190190
restConfig := helper.StartAPI(t)
191191

192-
reg, close := helper.StartRegistry(t)
193-
reg1, close1 := helper.StartRegistry(t)
194-
defer close()
195-
defer close1()
192+
reg, cancel := helper.StartRegistry(t)
193+
reg1, cancel1 := helper.StartRegistry(t)
194+
defer cancel()
195+
defer cancel1()
196196

197197
ctx := helper.GetCTX(t)
198198
kclient := helper.MustReturn(kclient.Default)

integration/client/imagerules/imageallowrules_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ import (
1818
func TestImageAllowRules(t *testing.T) {
1919
// TODO(@iwilltry42): Add test for auto-upgrade pattern
2020
helper.StartController(t)
21-
registry, close := helper.StartRegistry(t)
22-
defer close()
21+
registry, cancel := helper.StartRegistry(t)
22+
defer cancel()
2323

2424
ctx := helper.GetCTX(t)
2525
c, project := helper.ClientAndProject(t)
2626
kclient := helper.MustReturn(kclient.Default)
2727

2828
// enable image allow rules in acorn config
29-
helper.EnableFeatureWithRestore(t, ctx, kclient, profiles.FeatureImageAllowRules)
29+
helper.EnableFeatureWithRestore(ctx, t, kclient, profiles.FeatureImageAllowRules)
3030

3131
// Delete any existing IARs from this project namespace
3232
err := kclient.DeleteAllOf(ctx, &internalv1.ImageAllowRuleInstance{}, cclient.InNamespace(c.GetNamespace()))

integration/client/imagerules/imageroleauthorizations_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ var parentAcornfile []byte
3030

3131
func TestImageRoleAuthorizations(t *testing.T) {
3232
helper.StartController(t)
33-
registry, close := helper.StartRegistry(t)
34-
defer close()
33+
registry, cancel := helper.StartRegistry(t)
34+
defer cancel()
3535

3636
ctx := helper.GetCTX(t)
3737
c, _ := helper.ClientAndProject(t)
3838
kclient := helper.MustReturn(kclient.Default)
3939

4040
// enable image role authorizations in acorn config
41-
helper.EnableFeatureWithRestore(t, ctx, kclient, profiles.FeatureImageRoleAuthorizations)
41+
helper.EnableFeatureWithRestore(ctx, t, kclient, profiles.FeatureImageRoleAuthorizations)
4242

4343
// Delete any existing rules from this project namespace
4444
err := kclient.DeleteAllOf(ctx, &internaladminv1.ImageRoleAuthorizationInstance{}, cclient.InNamespace(c.GetNamespace()))
@@ -397,7 +397,7 @@ func TestImageRoleAuthorizationConsumerPerms(t *testing.T) {
397397
kclient := helper.MustReturn(kclient.Default)
398398

399399
// enable image role authorizations in acorn config
400-
helper.EnableFeatureWithRestore(t, ctx, kclient, profiles.FeatureImageRoleAuthorizations)
400+
helper.EnableFeatureWithRestore(ctx, t, kclient, profiles.FeatureImageRoleAuthorizations)
401401

402402
// Delete any existing rules from this project namespace
403403
err := kclient.DeleteAllOf(ctx, &internaladminv1.ImageRoleAuthorizationInstance{}, cclient.InNamespace(c.GetNamespace()))

integration/client/imagerules/signature_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616

1717
func TestImageSignVerify(t *testing.T) {
1818
helper.StartController(t)
19-
registry, close := helper.StartRegistry(t)
20-
defer close()
19+
registry, cancel := helper.StartRegistry(t)
20+
defer cancel()
2121

2222
ctx := helper.GetCTX(t)
2323
c, project := helper.ClientAndProject(t)

integration/client/images/images_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ func TestImageTag(t *testing.T) {
150150

151151
func TestImagePush(t *testing.T) {
152152
helper.StartController(t)
153-
registry, close := helper.StartRegistry(t)
154-
defer close()
153+
registry, cancel := helper.StartRegistry(t)
154+
defer cancel()
155155
restConfig := helper.StartAPI(t)
156156

157157
ctx := helper.GetCTX(t)
@@ -193,8 +193,8 @@ func TestImagePush(t *testing.T) {
193193

194194
func TestImagePull(t *testing.T) {
195195
helper.StartController(t)
196-
registry, close := helper.StartRegistry(t)
197-
defer close()
196+
registry, cancel := helper.StartRegistry(t)
197+
defer cancel()
198198
restConfig := helper.StartAPI(t)
199199

200200
ctx := helper.GetCTX(t)
@@ -268,8 +268,8 @@ func TestImagePull(t *testing.T) {
268268

269269
func TestImageDetails(t *testing.T) {
270270
helper.StartController(t)
271-
registry, close := helper.StartRegistry(t)
272-
defer close()
271+
registry, cancel := helper.StartRegistry(t)
272+
defer cancel()
273273
restConfig := helper.StartAPI(t)
274274

275275
ctx := helper.GetCTX(t)

integration/client/jobs/jobs_test.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
client2 "github.com/acorn-io/runtime/integration/client"
88
"github.com/acorn-io/runtime/integration/helper"
99
apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1"
10-
"github.com/acorn-io/runtime/pkg/client"
10+
rclient "github.com/acorn-io/runtime/pkg/client"
1111
kclient "github.com/acorn-io/runtime/pkg/k8sclient"
1212
"github.com/acorn-io/runtime/pkg/publicname"
1313
"github.com/stretchr/testify/assert"
@@ -26,7 +26,7 @@ func TestJobList(t *testing.T) {
2626
kclient := helper.MustReturn(kclient.Default)
2727
project := helper.TempProject(t, kclient)
2828

29-
c, err := client.New(restConfig, "", project.Name)
29+
c, err := rclient.New(restConfig, "", project.Name)
3030
require.NoError(t, err)
3131

3232
imageID := client2.NewImageWithJobs(t, project.Name)
@@ -58,7 +58,7 @@ func TestJobGet(t *testing.T) {
5858
kclient := helper.MustReturn(kclient.Default)
5959
project := helper.TempProject(t, kclient)
6060

61-
c, err := client.New(restConfig, "", project.Name)
61+
c, err := rclient.New(restConfig, "", project.Name)
6262
require.NoError(t, err)
6363

6464
imageID := client2.NewImageWithJobs(t, project.Name)
@@ -106,29 +106,27 @@ func TestJobRestart(t *testing.T) {
106106
lclient, err := kclient.New(restConfig)
107107
require.NoError(t, err)
108108

109-
kclient := helper.MustReturn(kclient.Default)
110-
project := helper.TempProject(t, kclient)
109+
client := helper.MustReturn(kclient.Default)
110+
project := helper.TempProject(t, client)
111111

112-
c, err := client.New(restConfig, "", project.Name)
112+
c, err := rclient.New(restConfig, "", project.Name)
113113
require.NoError(t, err)
114114

115-
imageID := client2.NewImageWithJobs(t, project.Name)
116-
app, err := c.AppRun(ctx, imageID, nil)
115+
app, err := c.AppRun(ctx, client2.NewImageWithJobs(t, project.Name), nil)
117116
require.NoError(t, err)
118117

119118
// Wait for the Job to initially complete
120119
var firstCompletion *metav1.Time
121-
helper.WaitForObject(t, lclient.Watch, &apiv1.AppList{}, app, func(app *apiv1.App) bool {
120+
app = helper.WaitForObject(t, lclient.Watch, &apiv1.AppList{}, app, func(app *apiv1.App) bool {
122121
firstCompletion = app.Status.AppStatus.Jobs["job"].CompletionTime
123-
return app.Status.Namespace != "" && app.Status.AppStatus.Jobs["job"].CompletionTime != nil
122+
return app.Status.AppStatus.Jobs["job"].CompletionTime != nil
124123
})
125124

126125
require.NoError(t, c.JobRestart(ctx, publicname.ForChild(app, "job")))
127126

128127
// Wait for the Job to complete again by checking for a difference in the completion time
129-
helper.WaitForObject(t, lclient.Watch, &apiv1.AppList{}, app, func(app *apiv1.App) bool {
130-
secondCompletion := app.Status.AppStatus.Jobs["job"].CompletionTime
131-
return app.Status.Namespace != "" && !firstCompletion.Equal(secondCompletion)
128+
app = helper.WaitForObject(t, lclient.Watch, &apiv1.AppList{}, app, func(app *apiv1.App) bool {
129+
return !firstCompletion.Equal(app.Status.AppStatus.Jobs["job"].CompletionTime)
132130
})
133131

134132
require.NoError(t, c.JobRestart(ctx, publicname.ForChild(app, "cronjob")))

integration/helper/assertions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func Subset[V, W any, Z comparable](t *testing.T, first []V, second []W, firstLo
1313

1414
set := make(map[Z]int)
1515
for _, value := range second {
16-
set[secondLookup(value)] += 1
16+
set[secondLookup(value)]++
1717
}
1818

1919
for _, value := range first {

0 commit comments

Comments
 (0)