From 7b9fb7ac873ef242a595d4ef6bcf7c17b1512f9b Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Fri, 11 Aug 2023 07:35:02 -0700 Subject: [PATCH] Add lint to check for known cross-module internal packages (#4426) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add depguard conf for cross-mod internal pkg check * Apply feedback * Apply suggestions from code review --------- Co-authored-by: Robert PajÄ…k --- .golangci.yml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index c0e4b95b23d..61782fbf0dd 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -73,6 +73,56 @@ linters-settings: - pkg: "crypto/md5" - pkg: "crypto/sha1" - pkg: "crypto/**/pkix" + otlp-internal: + files: + - "!**/exporters/otlp/internal/**/*.go" + # TODO: remove the following when otlpmetric/internal is removed. + - "!**/exporters/otlp/otlpmetric/internal/oconf/envconfig.go" + - "!**/exporters/otlp/otlpmetric/internal/oconf/options.go" + - "!**/exporters/otlp/otlpmetric/internal/oconf/options_test.go" + - "!**/exporters/otlp/otlpmetric/internal/otest/client_test.go" + deny: + - pkg: "go.opentelemetry.io/otel/exporters/otlp/internal" + desc: Do not use cross-module internal packages. + otlptrace-internal: + files: + - "!**/exporters/otlp/otlptrace/*.go" + - "!**/exporters/otlp/otlptrace/internal/**.go" + deny: + - pkg: "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal" + desc: Do not use cross-module internal packages. + otlpmetric-internal: + files: + - "!**/exporters/otlp/otlpmetric/internal/*.go" + - "!**/exporters/otlp/otlpmetric/internal/**/*.go" + deny: + - pkg: "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal" + desc: Do not use cross-module internal packages. + otel-internal: + files: + - "**/sdk/*.go" + - "**/sdk/**/*.go" + - "**/exporters/*.go" + - "**/exporters/**/*.go" + - "**/schema/*.go" + - "**/schema/**/*.go" + - "**/metric/*.go" + - "**/metric/**/*.go" + - "**/bridge/*.go" + - "**/bridge/**/*.go" + - "**/example/*.go" + - "**/example/**/*.go" + - "**/trace/*.go" + - "**/trace/**/*.go" + deny: + - pkg: "go.opentelemetry.io/otel/internal$" + desc: Do not use cross-module internal packages. + - pkg: "go.opentelemetry.io/otel/internal/attribute" + desc: Do not use cross-module internal packages. + - pkg: "go.opentelemetry.io/otel/internal/internaltest" + desc: Do not use cross-module internal packages. + - pkg: "go.opentelemetry.io/otel/internal/matchers" + desc: Do not use cross-module internal packages. godot: exclude: # Exclude links.