Skip to content

Commit 0570d97

Browse files
authored
lint: allow repo specific configs (istio#44130)
* lint: allow repo specific configs This is part of this, rest is in common-files. Basically, move per-repo settings into the repo. This allows us to expand our checks more aggresively where they don't make sense outside the repo. This is done by overriding the actual stored file which is a bit more managageble than overriding it on the fly since golangci-lint doesn't support config from stdin. * run update common * litn * rebase * rebase
1 parent 7bbcccd commit 0570d97

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

Makefile.overrides.mk

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
BUILD_WITH_CONTAINER ?= 1
2222
CONTAINER_OPTIONS = --mount type=bind,source=/tmp,destination=/tmp --net=host
2323

24+
export COMMONFILES_POSTPROCESS = tools/commonfiles-postprocess.sh
25+
2426
ifeq ($(BUILD_WITH_CONTAINER),1)
2527
# create phony targets for the top-level items in the repo
2628
PHONYS := $(shell ls | grep -v Makefile)

common/config/.golangci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ linters-settings:
233233
depguard:
234234
packages-with-error-message:
235235
- github.com/gogo/protobuf: "gogo/protobuf is deprecated, use golang/protobuf"
236+
golang.org/x/net/http2/h2c: "h2c.NewHandler is unsafe; use wrapper istio.io/istio/pkg/h2c"
237+
- github.com/golang/protobuf/jsonpb: "don't use the jsonpb package directly; use util/protomarshal instead"
238+
- google.golang.org/protobuf/encoding/protojson: "don't use the protojson package directly; use util/protomarshal instead"
236239
gosec:
237240
includes:
238241
- G401

tools/commonfiles-postprocess.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# Copyright Istio Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# shellcheck disable=SC2016
18+
yq ea '. as $item ireduce ({}; . *d $item )' ./common/config/.golangci.yml ./tools/golangci-override.yaml > ./common/config/.golangci.yml.tmp
19+
mv ./common/config/.golangci.yml.tmp ./common/config/.golangci.yml

tools/golangci-override.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
linters-settings:
2+
depguard:
3+
packages-with-error-message:
4+
- golang.org/x/net/http2/h2c: "h2c.NewHandler is unsafe; use wrapper istio.io/istio/pkg/h2c"
5+
- github.com/golang/protobuf/jsonpb: "don't use the jsonpb package directly; use util/protomarshal instead"
6+
- google.golang.org/protobuf/encoding/protojson: "don't use the protojson package directly; use util/protomarshal instead"

0 commit comments

Comments
 (0)