Skip to content

Commit 9b94460

Browse files
authored
Merge pull request #1813 from sigstore/update-golangci-lint
Update golangci-lint config to version 2
2 parents 042759b + 13fe05f commit 9b94460

File tree

6 files changed

+66
-46
lines changed

6 files changed

+66
-46
lines changed

.github/workflows/lint.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
12+
jobs:
13+
golangci:
14+
name: lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version-file: './go.mod'
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v7
23+
with:
24+
version: v2.0

.github/workflows/tests.yaml

-15
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,3 @@ jobs:
7979
run: |
8080
set -e
8181
addlicense -check -l apache -c 'The Sigstore Authors' -ignore "third_party/**" -v *
82-
83-
golangci:
84-
name: lint
85-
runs-on: ubuntu-latest
86-
steps:
87-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
88-
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
89-
with:
90-
go-version-file: './go.mod'
91-
check-latest: true
92-
- name: golangci-lint
93-
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
94-
with:
95-
version: v1.61
96-
args: --timeout=15m

.golangci.yml

+38-27
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,57 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
15+
version: "2"
16+
run:
17+
issues-exit-code: 1
1618
linters:
1719
enable:
1820
- asciicheck
19-
- errcheck
2021
- errorlint
21-
- gofmt
22-
- goimports
23-
- gosec
2422
- gocritic
23+
- gosec
2524
- importas
25+
- misspell
2626
- prealloc
2727
- revive
28-
- misspell
29-
- stylecheck
28+
- staticcheck
3029
- tparallel
3130
- unconvert
3231
- unparam
3332
- whitespace
34-
linters-settings:
35-
revive:
33+
settings:
34+
revive:
35+
rules:
36+
- name: dot-imports
37+
arguments:
38+
- allowedPackages:
39+
- knative.dev/pkg/configmap/testing
40+
- knative.dev/pkg/reconciler/testing
41+
- github.com/sigstore/policy-controller/pkg/reconciler/testing/v1alpha1
42+
exclusions:
43+
generated: lax
44+
presets:
45+
- comments
46+
- common-false-positives
47+
- legacy
48+
- std-error-handling
3649
rules:
37-
- name: dot-imports
38-
arguments:
39-
- allowedPackages:
40-
- "knative.dev/pkg/configmap/testing"
41-
- "knative.dev/pkg/reconciler/testing"
42-
- "github.com/sigstore/policy-controller/pkg/reconciler/testing/v1alpha1"
43-
output:
44-
uniq-by-line: false
50+
- linters:
51+
- errcheck
52+
- gosec
53+
path: _test\.go
54+
paths:
55+
- ^third_party/
56+
- ^examples/
4557
issues:
46-
exclude-rules:
47-
- path: _test\.go
48-
linters:
49-
- errcheck
50-
- gosec
5158
max-issues-per-linter: 0
5259
max-same-issues: 0
53-
run:
54-
issues-exit-code: 1
55-
timeout: 10m
56-
skip-dirs:
57-
- third_party
60+
formatters:
61+
enable:
62+
- gofmt
63+
- goimports
64+
exclusions:
65+
generated: lax
66+
paths:
67+
- ^third_party/
68+
- ^examples/

pkg/reconciler/testing/v1alpha1/clusterimagepolicy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func WithResourceVersion(resourceVersion string) ClusterImagePolicyOption {
5757

5858
func WithClusterImagePolicyDeletionTimestamp(cip *v1alpha1.ClusterImagePolicy) {
5959
t := metav1.NewTime(time.Unix(1e9, 0))
60-
cip.ObjectMeta.SetDeletionTimestamp(&t)
60+
cip.SetDeletionTimestamp(&t)
6161
}
6262

6363
func WithImagePattern(ip v1alpha1.ImagePattern) ClusterImagePolicyOption {

pkg/reconciler/testing/v1alpha1/trustroot.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func WithTrustRootResourceVersion(resourceVersion string) TrustRootOption {
5858

5959
func WithTrustRootDeletionTimestamp(tr *v1alpha1.TrustRoot) {
6060
t := metav1.NewTime(time.Unix(1e9, 0))
61-
tr.ObjectMeta.SetDeletionTimestamp(&t)
61+
tr.SetDeletionTimestamp(&t)
6262
}
6363

6464
func WithTrustRootFinalizer(tr *v1alpha1.TrustRoot) {

pkg/webhook/validator.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (v *Validator) ValidatePodScalable(ctx context.Context, ps *policyduckv1bet
152152

153153
// If we are being scaled down don't block it.
154154
if ps.IsScalingDown(ctx) {
155-
logging.FromContext(ctx).Debugf("Skipping validations due to scale down request %s/%s", &ps.ObjectMeta.Name, &ps.ObjectMeta.Namespace)
155+
logging.FromContext(ctx).Debugf("Skipping validations due to scale down request %s/%s", &ps.Name, &ps.Namespace)
156156
return nil
157157
}
158158

@@ -974,7 +974,7 @@ func (v *Validator) ResolvePodScalable(ctx context.Context, ps *policyduckv1beta
974974
}
975975

976976
if ps.IsScalingDown(ctx) {
977-
logging.FromContext(ctx).Debugf("Skipping validations due to scale down request %s/%s", &ps.ObjectMeta.Name, &ps.ObjectMeta.Namespace)
977+
logging.FromContext(ctx).Debugf("Skipping validations due to scale down request %s/%s", &ps.Name, &ps.Namespace)
978978
return
979979
}
980980

0 commit comments

Comments
 (0)