From bb4dd91c0790a1671ba0c5d95ba7589bdfd3356a Mon Sep 17 00:00:00 2001 From: Dominik Roos Date: Wed, 16 Mar 2022 09:02:48 +0100 Subject: [PATCH] repo: cleanup leftover references to the go directory GitOrigin-RevId: f4b252ddaa7c90ff7617965c1e5101d08ded422d --- .bazelignore | 1 - .editorconfig | 3 - .gitignore | 5 - gateway/routing/internal/fuzz/fuzz.go | 2 +- ineffassign.json | 3 - nogo.json | 245 ++++++++++-------- pkg/private/xtest/graphupdater/main.go | 2 +- pkg/scrypto/cppki/certs_test.go | 10 +- private/ca/renewal/grpc/delegating_handler.go | 2 +- router/control/conf.go | 2 +- scion.bzl | 2 +- tools/licensechecker.py | 25 +- tools/lint.sh | 12 +- tools/tools.go | 2 +- 14 files changed, 176 insertions(+), 140 deletions(-) delete mode 100644 ineffassign.json diff --git a/.bazelignore b/.bazelignore index d61d33aa9b..05b3443ccb 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1,4 +1,3 @@ bin docker/_build -go/vendor rules_openapi/tools/node_modules diff --git a/.editorconfig b/.editorconfig index 8adf289ca7..f0e9e20960 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,9 +15,6 @@ indent_style = tab [Makefile] indent_style = tab -[go/vendor/vendor.json] -indent_style = tab - [.gitmodules] indent_style = tab diff --git a/.gitignore b/.gitignore index c6ad81287a..6c2886bb43 100644 --- a/.gitignore +++ b/.gitignore @@ -24,10 +24,6 @@ Thumbs.db __pycache__ *.pyc -# Vendor linkfarm # -######################### -/go/vendor/*/ - # vim files # ######################### .*.sw? @@ -57,7 +53,6 @@ compile_commands.json ########################## /.coverage /python/htmlcov/ -/go/gocover.html # C library binaries ########################## diff --git a/gateway/routing/internal/fuzz/fuzz.go b/gateway/routing/internal/fuzz/fuzz.go index 7de927226f..4cfa3437b2 100644 --- a/gateway/routing/internal/fuzz/fuzz.go +++ b/gateway/routing/internal/fuzz/fuzz.go @@ -18,7 +18,7 @@ import ( "github.com/scionproto/scion/gateway/routing" ) -// For additional help, see: go/lib/slayers/internal/fuzz/README.md +// For additional help, see: pkg/slayers/internal/fuzz/README.md // Fuzz policy parsing. func Fuzz(data []byte) int { diff --git a/ineffassign.json b/ineffassign.json deleted file mode 100644 index 13d237890b..0000000000 --- a/ineffassign.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "go/antlr/sequence": "antlr4 generates files with inneffective assignments" -} diff --git a/nogo.json b/nogo.json index 64a63c9069..097333d9fd 100644 --- a/nogo.json +++ b/nogo.json @@ -1,109 +1,148 @@ { - "assign": { - "exclude_files": { - "gazelle/walk/walk.go": "", - "com_github_deepmap_oapi_codegen/pkg/codegen/": "" - } - }, - "composites": { - "exclude_files": { - "gazelle/language/go/resolve.go": "", - "/io_bazel_rules_docker/": "", - "/com_github_bazelbuild_buildtools/": "", - "/com_github_grpc_ecosystem_grpc_opentracing/go/otgrpc/": "", - "/com_github_vishvananda_netlink/": "", - "/org_golang_x_tools/internal": "", - "/org_golang_google_protobuf": "" - } - }, - "copylocks": { - "exclude_files": { - "/org_golang_google_protobuf/internal/impl/": "" - } - }, - "nilness": { - "only_files": { - "/go/": "https://github.com/bazelbuild/rules_go/issues/2172" + "assign": { + "exclude_files": { + "gazelle/walk/walk.go": "", + "com_github_deepmap_oapi_codegen/pkg/codegen/": "" + } }, - "exclude_files": { - "gazelle/cmd/gazelle/diff.go": "", - "/in_gopkg_yaml_v2/decode.go": "https://github.com/go-yaml/yaml/pull/492", - "/com_github_mattn_go_sqlite3": "", - "/com_github_lucas_clemente_quic_go": "", - "/com_github_cloudflare_sidh": "", - "/com_github_vishvananda_netlink": "" - } - }, - "printf": { - "exclude_files": { - "/com_github_cloudflare_sidh/": "" - } - }, - "stringintconv": { - "exclude_files": { - "/com_github_sergi_go_diff": "", - "/com_github_uber_jaeger_client_go": "", - "/com_github_google_gopacket": "", - "/net_starlark_go": "", - "/com_github_smartystreets_assertions/internal/go-diff/diffmatchpatch/patch.go": "" - } - }, - "unreachable": { - "exclude_files": { - "gazelle/pathtools/path.go": "", - "/com_github_antlr_antlr4_runtime_go_antlr/": "", - "/com_github_uber_jaeger_client_go": "", - "/com_github_marten_seemann_qtls/": "", - "/org_golang_google_protobuf/": "", - "/com_github_magiconair_properties": "", - "/com_github_ghodss_yaml/": "", - "/com_github_lestrrat_go_iter/mapiter/": "", - "/com_github_lestrrat_go_iter/arrayiter/": "" - } - }, - "unsafeptr": { - "only_files": { - "/go/": "https://github.com/bazelbuild/rules_go/issues/2172" + "composites": { + "exclude_files": { + "gazelle/language/go/resolve.go": "", + "/io_bazel_rules_docker/": "", + "/com_github_bazelbuild_buildtools/": "", + "/com_github_grpc_ecosystem_grpc_opentracing/go/otgrpc/": "", + "/com_github_vishvananda_netlink/": "", + "/org_golang_x_tools/internal": "", + "/org_golang_google_protobuf": "" + } }, - "exclude_files": { - "/com_github_mattn_go_sqlite3/": "", - "/com_github_google_gopacket/afpacket/": "" - } - }, - "shift": { - "exclude_files": { - "/com_github_marten_seemann_qtls/": "" - } - }, - "stdmethods": { - "exclude_files": { - "/com_github_uber_jaeger_client_go": "" - } - }, - "structtag": { - "exclude_files": { - "com_github_buildkite_go_buildkite": "" - } - }, - "gocall": { - "only_files": { - "/go/": "https://github.com/bazelbuild/rules_go/issues/2172" + "copylocks": { + "exclude_files": { + "/org_golang_google_protobuf/internal/impl/": "" + } }, - "exclude_files": { - "(vendor|external)/*": "Only applies to internal files", - "xtest/*": "", - "_test.go": "Doesn't apply for test files" - } - }, - "lostcancel": { - "exclude_files": { - "com_github_grpc_ecosystem_go_grpc_middleware/retry": "" - } - }, - "maincheck": { - "exclude_files": { - "/com_github_deepmap_oapi_codegen/": "", - "/com_github_golang_mock/mockgen": "" + "nilness": { + "only_files": { + "/acceptance/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/antlr/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/control/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/daemon/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/demo/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/dispatcher/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/gateway/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/pkg/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/private/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/router/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/rules_openapi/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/scion/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/scion-pki/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/tools/": "https://github.com/bazelbuild/rules_go/issues/2172" + }, + "exclude_files": { + "gazelle/cmd/gazelle/diff.go": "", + "/in_gopkg_yaml_v2/decode.go": "https://github.com/go-yaml/yaml/pull/492", + "/com_github_mattn_go_sqlite3": "", + "/com_github_lucas_clemente_quic_go": "", + "/com_github_cloudflare_sidh": "", + "/com_github_vishvananda_netlink": "" + } + }, + "printf": { + "exclude_files": { + "/com_github_cloudflare_sidh/": "" + } + }, + "stringintconv": { + "exclude_files": { + "/com_github_sergi_go_diff": "", + "/com_github_uber_jaeger_client_go": "", + "/com_github_google_gopacket": "", + "/net_starlark_go": "", + "/com_github_smartystreets_assertions/internal/go-diff/diffmatchpatch/patch.go": "" + } + }, + "unreachable": { + "exclude_files": { + "gazelle/pathtools/path.go": "", + "/com_github_antlr_antlr4_runtime_go_antlr/": "", + "/com_github_uber_jaeger_client_go": "", + "/com_github_marten_seemann_qtls/": "", + "/org_golang_google_protobuf/": "", + "/com_github_magiconair_properties": "", + "/com_github_ghodss_yaml/": "", + "/com_github_lestrrat_go_iter/mapiter/": "", + "/com_github_lestrrat_go_iter/arrayiter/": "" + } + }, + "unsafeptr": { + "only_files": { + "/acceptance/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/antlr/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/control/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/daemon/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/demo/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/dispatcher/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/gateway/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/pkg/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/private/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/router/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/rules_openapi/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/scion/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/scion-pki/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/tools/": "https://github.com/bazelbuild/rules_go/issues/2172" + }, + "exclude_files": { + "/com_github_mattn_go_sqlite3/": "", + "/com_github_google_gopacket/afpacket/": "" + } + }, + "shift": { + "exclude_files": { + "/com_github_marten_seemann_qtls/": "" + } + }, + "stdmethods": { + "exclude_files": { + "/com_github_uber_jaeger_client_go": "" + } + }, + "structtag": { + "exclude_files": { + "com_github_buildkite_go_buildkite": "" + } + }, + "gocall": { + "only_files": { + "/acceptance/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/antlr/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/control/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/daemon/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/demo/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/dispatcher/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/gateway/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/pkg/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/private/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/router/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/rules_openapi/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/scion/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/scion-pki/": "https://github.com/bazelbuild/rules_go/issues/2172", + "/tools/": "https://github.com/bazelbuild/rules_go/issues/2172" + }, + "exclude_files": { + "(vendor|external)/*": "Only applies to internal files", + "xtest/*": "", + "_test.go": "Doesn't apply for test files" + } + }, + "lostcancel": { + "exclude_files": { + "com_github_grpc_ecosystem_go_grpc_middleware/retry": "" + } + }, + "maincheck": { + "exclude_files": { + "/com_github_deepmap_oapi_codegen/": "", + "/com_github_golang_mock/mockgen": "" + } } - } } diff --git a/pkg/private/xtest/graphupdater/main.go b/pkg/private/xtest/graphupdater/main.go index 4379b10b58..da2355ea33 100644 --- a/pkg/private/xtest/graphupdater/main.go +++ b/pkg/private/xtest/graphupdater/main.go @@ -22,7 +22,7 @@ import ( const ( DefaultTopoFile = "topology/default.topo" - DefaultGenFile = "go/lib/xtest/graph/default_gen.go" + DefaultGenFile = "pkg/private/xtest/graph/default_gen.go" ) var ( diff --git a/pkg/scrypto/cppki/certs_test.go b/pkg/scrypto/cppki/certs_test.go index 69cce2ca83..fd2d5bff10 100644 --- a/pkg/scrypto/cppki/certs_test.go +++ b/pkg/scrypto/cppki/certs_test.go @@ -787,14 +787,14 @@ func TestVerifyChain(t *testing.T) { // testadata files generated with scion-pki: /* scion-pki testcrypto -t topology/default.topo -o gen - cp gen/ISD1/ISD1-B1-S1.trc go/lib/scrypto/cppki/testdata/verifychain - cp gen/ISD2/ISD2-B1-S1.trc go/lib/scrypto/cppki/testdata/verifychain + cp gen/ISD1/ISD1-B1-S1.trc pkg/scrypto/cppki/testdata/verifychain + cp gen/ISD2/ISD2-B1-S1.trc pkg/scrypto/cppki/testdata/verifychain cp gen/ISD1/ASff00_0_111/certs/ISD1-ASff00_0_111.pem \ - go/lib/scrypto/cppki/testdata/verifychain + pkg/scrypto/cppki/testdata/verifychain cp gen/ISD1/ASff00_0_110/certs/ISD1-ASff00_0_110.pem \ - go/lib/scrypto/cppki/testdata/verifychain + pkg/scrypto/cppki/testdata/verifychain cp gen/ISD2/ASff00_0_210/certs/ISD2-ASff00_0_210.pem \ - go/lib/scrypto/cppki/testdata/verifychain + pkg/scrypto/cppki/testdata/verifychain */ trc := loadTRC(t, "testdata/verifychain/ISD1-B1-S1.trc") diff --git a/private/ca/renewal/grpc/delegating_handler.go b/private/ca/renewal/grpc/delegating_handler.go index 30bfb49bf3..0f26b05cea 100644 --- a/private/ca/renewal/grpc/delegating_handler.go +++ b/private/ca/renewal/grpc/delegating_handler.go @@ -35,7 +35,7 @@ import ( ) // CAServiceClient is the minimal interface that is needed from -// go/pkg/ca/api:ClientWithResponsesInterface. +// private/ca/api:ClientWithResponsesInterface. type CAServiceClient interface { PostCertificateRenewal( ctx context.Context, diff --git a/router/control/conf.go b/router/control/conf.go index 0925cffc53..b11e4c27d4 100644 --- a/router/control/conf.go +++ b/router/control/conf.go @@ -148,7 +148,7 @@ func DeriveHFMacKey(k []byte) []byte { if len(k) == 0 { panic("empty key") } - // XXX Generate keys - MUST be kept in sync with go/lib/scrypto/mac.go + // XXX Generate keys - MUST be kept in sync with pkg/scrypto/mac.go hfMacSalt := []byte("Derive OF Key") // This uses 16B keys with 1000 hash iterations, which is the same as the // defaults used by pycrypto. diff --git a/scion.bzl b/scion.bzl index d540180f02..562e54ada1 100644 --- a/scion.bzl +++ b/scion.bzl @@ -4,6 +4,6 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary") def scion_go_binary(*args, **kwargs): x_defs = kwargs.get("x_defs", {}) x_defs.update({ - "github.com/scionproto/scion/go/lib/env.StartupVersion": "{STABLE_GIT_VERSION}", + "github.com/scionproto/scion/private/env.StartupVersion": "{STABLE_GIT_VERSION}", }) go_binary(x_defs = x_defs, *args, **kwargs) diff --git a/tools/licensechecker.py b/tools/licensechecker.py index 4f41b58aad..da32fbbd84 100755 --- a/tools/licensechecker.py +++ b/tools/licensechecker.py @@ -4,7 +4,8 @@ import subprocess license_texts = { - "#":""" + "#": + """ # 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 @@ -17,7 +18,8 @@ # See the License for the specific language governing permissions and # limitations under the License. """, - "//": """ + "//": + """ // 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 @@ -33,25 +35,29 @@ } exceptions = [ - "go/lib/scrypto/cms", - "go/lib/serrors/stack.go", - "go/lib/util/duration.go", - "go/scion-pki/certs/certinfo.go", - "go/scion-pki/certs/certformat.go", + "pkg/scrypto/cms", + "pkg/private/serrors/stack.go", + "pkg/private/util/duration.go", + "scion-pki/certs/certinfo.go", + "scion-pki/certs/certformat.go", ] + def is_ignored(f: str) -> bool: for e in exceptions: if e in f: return True return False + def main(): not_ok = {} for f in sys.argv[1:]: if is_ignored(f): continue - header = subprocess.check_output("head -15 %s" % f, stderr=subprocess.STDOUT, shell=True) + header = subprocess.check_output("head -15 %s" % f, + stderr=subprocess.STDOUT, + shell=True) lines = header.splitlines() if len(lines) < 1: not_ok[f] = "empty file" @@ -64,7 +70,8 @@ def main(): if not first_line.startswith(comment_marker): comment_marker = "#" if not first_line.startswith(comment_marker): - not_ok[f] = "no comment / unknown comment marker: %s" % first_line + not_ok[ + f] = "no comment / unknown comment marker: %s" % first_line continue if license_texts[comment_marker] not in header.decode("utf-8"): not_ok[f] = "missing licence" diff --git a/tools/lint.sh b/tools/lint.sh index b52825f9d5..07985cc117 100755 --- a/tools/lint.sh +++ b/tools/lint.sh @@ -21,13 +21,15 @@ run_silently() { go_lint() { lint_header "go" local TMPDIR=$(mktemp -d /tmp/scion-lint.XXXXXXX) - local LOCAL_DIRS="$(find go/* -maxdepth 0 -type d | grep -v vendor)" + local LOCAL_DIRS="$(find ./* -maxdepth 0 -type d )" # Find go files to lint, excluding generated code. For linelen and misspell. - find go acceptance -type f -iname '*.go' \ + find $LOCAL_DIRS -type f -iname '*.go' \ -a '!' -ipath '*.pb.go' \ -a '!' -ipath '*.gen.go' \ - -a '!' -ipath 'go/scion-pki/certs/certinfo.go' \ - -a '!' -ipath 'go/scion-pki/certs/certformat.go' \ + -a '!' -ipath './antlr/*' \ + -a '!' -ipath '*/node_modules/*' \ + -a '!' -ipath './scion-pki/certs/certinfo.go' \ + -a '!' -ipath './scion-pki/certs/certformat.go' \ -a '!' -ipath '*mock_*' > $TMPDIR/gofiles.list lint_step "Building lint tools" @@ -39,7 +41,7 @@ go_lint() { # See: https://github.com/bazelbuild/rules_go/issues/511 # Instead we'll just run the commands from Go SDK directly. GOSDK=$(bazel info output_base 2>/dev/null)/external/go_sdk/bin - out=$($GOSDK/gofmt -d -s $LOCAL_DIRS ./acceptance); + out=$($GOSDK/gofmt -d -s $( cat $TMPDIR/gofiles.list) ); if [ -n "$out" ]; then in_red "$out"; ret=1; fi lint_step "linelen (lll)" out=$($TMPDIR/lll -w 4 -l 100 --files -e '`comment:"|`ini:"|https?:|`sql:"|gorm:"|`json:"|`yaml:|nolint:lll' < $TMPDIR/gofiles.list) diff --git a/tools/tools.go b/tools/tools.go index f591519e6b..1d5c557cd8 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -17,7 +17,7 @@ package enum import ( - // rules_docker uses this project as a dependency. We import it explicitely + // rules_docker uses this project as a dependency. We import it explicitly // to overwrite it and force the use of goproxy. // See: https://github.com/bazelbuild/rules_docker/blob/master/repositories/go_repositories.bzl _ "github.com/google/go-containerregistry/cmd/registry"