diff --git a/.commonfiles.sha b/.commonfiles.sha deleted file mode 100644 index 4f13ae67fbb2..000000000000 --- a/.commonfiles.sha +++ /dev/null @@ -1 +0,0 @@ -e7512685241115f42cbb3ed7856a4a2a12057536 diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index 92f36e352abf..000000000000 --- a/.golangci.yml +++ /dev/null @@ -1,194 +0,0 @@ -# WARNING: DO NOT EDIT, THIS FILE IS PROBABLY A COPY -# -# The original version of this file is located in the https://github.com/istio/common-files repo. -# If you're looking at this file in a different repo and want to make a change, please go to the -# common-files repo, make the change there and check it in. Then come back to this repo and run -# "make updatecommon". - -service: - # When updating this, also update bin/linters.sh accordingly - golangci-lint-version: 1.18.x # use the fixed version to not introduce new linters unexpectedly -run: - # timeout for analysis, e.g. 30s, 5m, default is 1m - deadline: 20m - - # which dirs to skip: they won't be analyzed; - # can use regexp here: generated.*, regexp is applied on full path; - # default value is empty list, but next dirs are always skipped independently - # from this option's value: - # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs: - - genfiles$ - - vendor$ - - # which files to skip: they will be analyzed, but issues from them - # won't be reported. Default value is empty list, but there is - # no need to include all autogenerated files, we confidently recognize - # autogenerated files. If it's not please let us know. - skip-files: - - ".*\\.pb\\.go" - - ".*\\.gen\\.go" - -linters: - enable-all: true - disable: - - depguard - - dupl - - gochecknoglobals - - gochecknoinits - - goconst - - gocyclo - - gosec - - nakedret - - prealloc - - scopelint - - funlen - - bodyclose - fast: false - -linters-settings: - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: false - - # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; - # default is false: such cases aren't reported by default. - check-blank: false - govet: - # report about shadowed variables - check-shadowing: false - golint: - # minimal confidence for issues, default is 0.8 - min-confidence: 0.0 - gofmt: - # simplify code: gofmt with `-s` option, true by default - simplify: true - goimports: - # put imports beginning with prefix after 3rd-party packages; - # it's a comma-separated list of prefixes - local-prefixes: istio.io/ - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - misspell: - # Correct spellings using locale preferences for US or UK. - # Default is to use a neutral variety of English. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - locale: US - ignore-words: - - cancelled - lll: - # max line length, lines longer will be reported. Default is 120. - # '\t' is counted as 1 character by default, and can be changed with the tab-width option - line-length: 160 - # tab width in spaces. Default to 1. - tab-width: 1 - unused: - # treat code as a program (not a library) and report unused exported identifiers; default is false. - # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: - # if it's called for subdir of a project it can't find funcs usages. All text editor integrations - # with golangci-lint call it on a directory with the changed file. - check-exported: false - unparam: - # call graph construction algorithm (cha, rta). In general, use cha for libraries, - # and rta for programs with main packages. Default is cha. - algo: cha - - # Inspect exported functions, default is false. Set to true if no external program/library imports your code. - # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: - # if it's called for subdir of a project it can't find external interfaces. All text editor integrations - # with golangci-lint call it on a directory with the changed file. - check-exported: false - gocritic: - enabled-checks: - - appendCombine - - argOrder - - assignOp - - badCond - - boolExprSimplify - - builtinShadow - - captLocal - - caseOrder - - codegenComment - - commentedOutCode - - commentedOutImport - - defaultCaseOrder - - deprecatedComment - - docStub - - dupArg - - dupBranchBody - - dupCase - - dupSubExpr - - elseif - - emptyFallthrough - - equalFold - - flagDeref - - flagName - - hexLiteral - - indexAlloc - - initClause - - methodExprCall - - nilValReturn - - octalLiteral - - offBy1 - - rangeExprCopy - - regexpMust - - sloppyLen - - stringXbytes - - switchTrue - - typeAssertChain - - typeSwitchVar - - typeUnparen - - underef - - unlambda - - unnecessaryBlock - - unslice - - valSwap - - weakCond - - # Unused - # - yodaStyleExpr - # - appendAssign - # - commentFormatting - # - emptyStringTest - # - exitAfterDefer - # - ifElseChain - # - hugeParam - # - importShadow - # - nestingReduce - # - paramTypeCombine - # - ptrToRefParam - # - rangeValCopy - # - singleCaseSwitch - # - sloppyReassign - # - unlabelStmt - # - unnamedResult - # - wrapperFunc - -issues: - # List of regexps of issue texts to exclude, empty list by default. - # But independently from this option we use default exclude patterns, - # it can be disabled by `exclude-use-default: false`. To list all - # excluded by default patterns execute `golangci-lint run --help` - exclude: - - composite literal uses unkeyed fields - - exclude-rules: - # Exclude some linters from running on test files. - - path: _test\.go$|^tests/|^samples/ - linters: - - errcheck - - maligned - - # Independently from option `exclude` we use default exclude patterns, - # it can be disabled by this option. To list all - # excluded by default patterns execute `golangci-lint run --help`. - # Default value for this option is true. - exclude-use-default: true - - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-per-linter: 0 - - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. - max-same-issues: 0 diff --git a/Makefile.core.mk b/Makefile.core.mk index 4be85c61a9c2..e72f486a3b66 100644 --- a/Makefile.core.mk +++ b/Makefile.core.mk @@ -344,6 +344,11 @@ shellcheck: MARKDOWN_LINT_WHITELIST=localhost:8080,storage.googleapis.com/istio-artifacts/pilot/,http://ratings.default.svc.cluster.local:9080/ratings lint_modern: lint-python lint-copyright-banner lint-scripts lint-dockerfiles lint-markdown lint-yaml + @bin/check_helm.sh + @GOARCH=amd64 GOOS=linux bin/check_samples.sh + @GOARCH=amd64 GOOS=linux bin/check_dashboards.sh + @GOARCH=amd64 GOOS=linux go run mixer/tools/adapterlinter/main.go ./mixer/adapter/... + @GOARCH=amd64 GOOS=linux bin/check_pilot_codegen.sh @golangci-lint run -c ./common/config/.golangci.yml ./galley/... @golangci-lint run -c ./common/config/.golangci.yml ./istioctl/... @golangci-lint run -c ./common/config/.golangci.yml ./mixer/... diff --git a/bin/check_helm.sh b/bin/check_helm.sh new file mode 100755 index 000000000000..a72c356488f5 --- /dev/null +++ b/bin/check_helm.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Copyright Istio Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOTDIR=$(dirname "${SCRIPTPATH}") +cd "${ROOTDIR}" + +helm lint ./install/kubernetes/helm/istio +helm template install/kubernetes/helm/istio --name istio --namespace istio-system -x templates/configmap.yaml | grep -q " $" && echo "templates/configmap.yaml has trailing spaces" && exit 1 +helm template install/kubernetes/helm/istio --name istio --namespace istio-system -x templates/sidecar-injector-configmap.yaml | grep -q " $" && exit 1 + +exit 0 diff --git a/bin/yaml_lint.sh b/bin/yaml_lint.sh index d0f7874cae53..b8bcbc7df2b2 100755 --- a/bin/yaml_lint.sh +++ b/bin/yaml_lint.sh @@ -23,9 +23,4 @@ SCRIPTPATH=$( cd "$(dirname "$0")" ; pwd -P ) ROOTDIR=$SCRIPTPATH/.. cd "$ROOTDIR" -PKGS=${PKGS:-"."} -if [[ -z ${YAML_FILES} ]];then - find "${PKGS}" -type f -name '*.yaml' | grep -v ./vendor | grep -v -E "\/templates\/" | grep -v -E "template" | xargs yamllint -c ./bin/yamllintrules -fi - -exit $? \ No newline at end of file +find . \( -path ./common-protos -o -path ./.git -o -path ./.github \) -prune -o -type f \( -name '*.yml' -o -name '*.yaml' \) -print0 | xargs -0 grep -L -e "{{" | xargs yamllint -c ./common/config/.yamllint.yml diff --git a/bin/yamllintrules b/bin/yamllintrules deleted file mode 100755 index c557d119960b..000000000000 --- a/bin/yamllintrules +++ /dev/null @@ -1,37 +0,0 @@ ---- -ignore: | - /tests/e2e/tests/pilot/testdata/networking/v1alpha3/rule-503test-destinationrule-c.yaml - /tests/e2e/tests/pilot/testdata/networking/v1alpha3/destination-rule-c.yaml - /tests/e2e/tests/pilot/testdata/networking/v1alpha3/rule-503test-destinationrule-c-add-subset.yaml - /tests/e2e/tests/pilot/testdata/networking/v1alpha3/rule-503test-destinationrule-c-del-subset.yaml - /tests/e2e/tests/pilot/testdata/networking/v1alpha3/destination-rule-c-private.yaml - -rules: - braces: disable - brackets: disable - colons: - ignore: | - /galley/tools/gen-meta/metadata.yaml - /galley/pkg/config/processor/metadata/metadata.yaml - /galley/pkg/config/testing/basicmeta/basicmeta.yaml - /galley/pkg/config/testing/basicmeta/basicmeta2.yaml - /galley/pkg/config/testing/k8smeta/k8smeta.yaml - /pkg/config/schemas/schemagen/schemas.yaml - commas: disable - comments: disable - comments-indentation: disable - document-end: disable - document-start: disable - empty-lines: disable - empty-values: enable - hyphens: enable - indentation: disable - key-duplicates: enable - key-ordering: disable - line-length: disable - new-line-at-end-of-file: disable - new-lines: enable - octal-values: enable - quoted-strings: disable - trailing-spaces: disable - truthy: disable diff --git a/scripts/run_golangci.sh b/scripts/run_golangci.sh index 208b57d97dde..a35bb23b25e6 100755 --- a/scripts/run_golangci.sh +++ b/scripts/run_golangci.sh @@ -37,4 +37,4 @@ GOLANGCI_VERSION="v1.18.0" curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b "$GOPATH"/bin "$GOLANGCI_VERSION" golangci-lint --version # For tuning and when switching versions PLEASE REFERENCE: https://github.com/istio/istio/issues/14888 -env GOGC=25 golangci-lint run ${FIX} -v ./... +env GOGC=25 golangci-lint run -c ./common/config/.golangci.yml ${FIX} -v ./...