diff --git a/.github/workflows/buf-binary-size.yaml b/.github/workflows/buf-binary-size.yaml index 61b7f0f487..6276a34f4f 100644 --- a/.github/workflows/buf-binary-size.yaml +++ b/.github/workflows/buf-binary-size.yaml @@ -14,7 +14,7 @@ jobs: - name: setup-go uses: actions/setup-go@v5 with: - go-version: '1.22.x' + go-version: '1.23.x' - name: cache uses: actions/cache@v4 with: diff --git a/.github/workflows/build-and-draft-release.yaml b/.github/workflows/build-and-draft-release.yaml index b9bbf79ef2..8c65b96355 100644 --- a/.github/workflows/build-and-draft-release.yaml +++ b/.github/workflows/build-and-draft-release.yaml @@ -32,7 +32,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22.x' + go-version: '1.23.x' - name: Set up Git name and email run: | git config user.name "${{ github.actor }}" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2609858fd4..6eee11c16d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: - name: setup-go uses: actions/setup-go@v5 with: - go-version: '1.22.x' + go-version: '1.23.x' - name: cache uses: actions/cache@v4 with: @@ -50,7 +50,7 @@ jobs: - name: setup-go uses: actions/setup-go@v5 with: - go-version: '1.22.x' + go-version: '1.23.x' - name: cache uses: actions/cache@v4 with: diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 012c81ca00..fc6f3369e6 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -21,7 +21,7 @@ jobs: - name: setup-go uses: actions/setup-go@v5 with: - go-version: '1.22.x' + go-version: '1.23.x' - name: initialize uses: github/codeql-action/init@v3 with: diff --git a/.github/workflows/previous.yaml b/.github/workflows/previous.yaml index 84053bd408..fe81dbad7c 100644 --- a/.github/workflows/previous.yaml +++ b/.github/workflows/previous.yaml @@ -9,7 +9,7 @@ jobs: test-previous: strategy: matrix: - go-version: ['1.20.x', '1.21.x'] + go-version: ['1.21.x', '1.22.x'] runs-on: ubuntu-latest steps: - name: checkout diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index 877f6a2564..1b1b6b2f3f 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -21,7 +21,7 @@ jobs: - name: setup-go uses: actions/setup-go@v5 with: - go-version: '1.22.x' + go-version: '1.23.x' cache: true - name: windows-cache uses: actions/cache@v4 diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 3ba6669191..32a43194a4 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,42 +1,42 @@ - id: buf-generate name: buf generate language: golang - language_version: 1.22.1 + language_version: 1.23.0 entry: buf generate types: [proto] pass_filenames: false - id: buf-breaking name: buf breaking language: golang - language_version: 1.22.1 + language_version: 1.23.0 entry: buf breaking types: [proto] pass_filenames: false - id: buf-lint name: buf lint language: golang - language_version: 1.22.1 + language_version: 1.23.0 entry: buf lint types: [proto] pass_filenames: false - id: buf-format name: buf format language: golang - language_version: 1.22.1 + language_version: 1.23.0 entry: buf format -w --exit-code types: [proto] pass_filenames: false - id: buf-dep-update name: buf dep update language: golang - language_version: 1.22.1 + language_version: 1.23.0 entry: buf dep update files: '(buf\.lock|buf\.yaml)' pass_filenames: false - id: buf-dep-prune name: buf dep prune language: golang - language_version: 1.22.1 + language_version: 1.23.0 entry: buf dep prune files: '(buf\.lock|buf\.yaml)' pass_filenames: false @@ -44,7 +44,7 @@ - id: buf-mod-update name: buf mod update language: golang - language_version: 1.22.1 + language_version: 1.23.0 entry: buf mod update files: '(buf\.lock|buf\.yaml)' pass_filenames: false @@ -52,7 +52,7 @@ - id: buf-mod-prune name: buf mod prune language: golang - language_version: 1.22.1 + language_version: 1.23.0 entry: buf mod prune files: '(buf\.lock|buf\.yaml)' pass_filenames: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 51826d779f..f904fe49e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ - No changes yet. +## [v1.37.0] - 2024-08-16 + +- Add `STABLE_PACKAGE_NO_IMPORT_UNSTABLE` lint rule which disallows files from stable packages + to import files from unstable packages. +- Fix plugin push failures when pushing an image built with containerd image store. + ## [v1.36.0] - 2024-08-06 - Add `--list-services` and `--list-methods` flags to `buf curl`, which trigger the command to list @@ -1202,7 +1208,8 @@ buf check breaking proto --against .git#branch=master,subdir=proto Initial beta release. -[Unreleased]: https://github.com/bufbuild/buf/compare/v1.36.0...HEAD +[Unreleased]: https://github.com/bufbuild/buf/compare/v1.37.0...HEAD +[v1.37.0]: https://github.com/bufbuild/buf/compare/v1.36.0...v1.37.0 [v1.36.0]: https://github.com/bufbuild/buf/compare/v1.35.1...v1.36.0 [v1.35.1]: https://github.com/bufbuild/buf/compare/v1.35.0...v1.35.1 [v1.35.0]: https://github.com/bufbuild/buf/compare/v1.34.0...v1.35.0 diff --git a/go.mod b/go.mod index 7f86c95206..40efebfe34 100644 --- a/go.mod +++ b/go.mod @@ -1,24 +1,26 @@ module github.com/bufbuild/buf -go 1.20 +go 1.21.0 + +toolchain go1.23.0 require ( - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240508200655-46a4cf4ba109.2 - buf.build/gen/go/bufbuild/registry/connectrpc/go v1.16.2-20240610164129-660609bc46d3.1 - buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.34.2-20240610164129-660609bc46d3.2 + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2 + buf.build/gen/go/bufbuild/registry/connectrpc/go v1.16.2-20240801134127-09fbc17f7c9e.1 + buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.34.2-20240801134127-09fbc17f7c9e.2 connectrpc.com/connect v1.16.2 - connectrpc.com/otelconnect v0.7.0 + connectrpc.com/otelconnect v0.7.1 github.com/bufbuild/protocompile v0.14.0 github.com/bufbuild/protoplugin v0.0.0-20240323223605-e2735f6c31ee - github.com/bufbuild/protovalidate-go v0.6.2 - github.com/bufbuild/protoyaml-go v0.1.9 - github.com/docker/docker v27.0.0+incompatible - github.com/go-chi/chi/v5 v5.0.14 - github.com/gofrs/flock v0.8.1 - github.com/gofrs/uuid/v5 v5.2.0 - github.com/google/cel-go v0.20.1 + github.com/bufbuild/protovalidate-go v0.6.4 + github.com/bufbuild/protoyaml-go v0.1.11 + github.com/docker/docker v27.1.2+incompatible + github.com/go-chi/chi/v5 v5.1.0 + github.com/gofrs/flock v0.12.1 + github.com/gofrs/uuid/v5 v5.3.0 + github.com/google/cel-go v0.21.0 github.com/google/go-cmp v0.6.0 - github.com/google/go-containerregistry v0.19.2 + github.com/google/go-containerregistry v0.20.2 github.com/jdx/go-netrc v1.0.0 github.com/jhump/protoreflect v1.16.0 github.com/klauspost/compress v1.17.9 @@ -29,34 +31,41 @@ require ( github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/otel v1.24.0 - go.opentelemetry.io/otel/sdk v1.24.0 - go.opentelemetry.io/otel/trace v1.24.0 + go.opentelemetry.io/otel v1.28.0 + go.opentelemetry.io/otel/sdk v1.28.0 + go.opentelemetry.io/otel/trace v1.28.0 go.uber.org/atomic v1.11.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 - golang.org/x/crypto v0.24.0 - golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 - golang.org/x/mod v0.18.0 - golang.org/x/net v0.26.0 - golang.org/x/sync v0.7.0 - golang.org/x/term v0.21.0 - golang.org/x/tools v0.22.0 + golang.org/x/crypto v0.26.0 + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa + golang.org/x/mod v0.20.0 + golang.org/x/net v0.28.0 + golang.org/x/sync v0.8.0 + golang.org/x/term v0.23.0 + golang.org/x/tools v0.24.0 google.golang.org/protobuf v1.34.2 gopkg.in/yaml.v3 v3.0.1 ) require ( github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect + github.com/Microsoft/hcsshim v0.12.5 // indirect github.com/antlr4-go/antlr/v4 v4.13.0 // indirect - github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/containerd/cgroups/v3 v3.0.3 // indirect + github.com/containerd/containerd v1.7.20 // indirect + github.com/containerd/continuity v0.4.3 // indirect + github.com/containerd/errdefs v0.1.0 // indirect github.com/containerd/log v0.1.0 // indirect + github.com/containerd/platforms v0.2.1 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect + github.com/containerd/ttrpc v1.2.5 // indirect + github.com/containerd/typeurl/v2 v2.2.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/docker/cli v26.1.4+incompatible // indirect + github.com/docker/cli v27.1.2+incompatible // indirect github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.2 // indirect github.com/docker/go-connections v0.5.0 // indirect @@ -66,29 +75,38 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/google/pprof v0.0.0-20240622144329-c177fd99eaa9 // indirect + github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/kr/pretty v0.3.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/moby/locker v1.0.1 // indirect + github.com/moby/patternmatcher v0.6.0 // indirect + github.com/moby/sys/mount v0.3.4 // indirect + github.com/moby/sys/mountinfo v0.7.2 // indirect + github.com/moby/sys/sequential v0.6.0 // indirect + github.com/moby/sys/user v0.3.0 // indirect + github.com/moby/sys/userns v0.1.0 // indirect github.com/moby/term v0.5.0 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect + github.com/opencontainers/runtime-spec v1.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.10.0 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect github.com/vbatts/tar-split v0.11.5 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/proto/otlp v1.3.1 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect + go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect + go.opentelemetry.io/otel/metric v1.28.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.17.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/grpc v1.65.0 // indirect ) diff --git a/go.sum b/go.sum index f94b344272..08cbb42c88 100644 --- a/go.sum +++ b/go.sum @@ -1,29 +1,36 @@ -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240508200655-46a4cf4ba109.2 h1:cFrEG/pJch6t62+jqndcPXeTNkYcztS4tBRgNkR+drw= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240508200655-46a4cf4ba109.2/go.mod h1:ylS4c28ACSI59oJrOdW4pHS4n0Hw4TgSPHn8rpHl4Yw= -buf.build/gen/go/bufbuild/registry/connectrpc/go v1.16.2-20240610164129-660609bc46d3.1 h1:PmSlGbLLyhKIAm46ROmzdGVaaYgDdFsQNA+VftjuCLs= -buf.build/gen/go/bufbuild/registry/connectrpc/go v1.16.2-20240610164129-660609bc46d3.1/go.mod h1:4ptL49VoWyYwajT6j4zu5vmQ/k/om4tGMB9atY2FhEo= -buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.34.2-20240610164129-660609bc46d3.2 h1:y1+UxFIWzj/eF2RCPqt9egR7Rt9vgQkXNUzSdmR6iEU= -buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.34.2-20240610164129-660609bc46d3.2/go.mod h1:psseUmlKRo9v5LZJtR/aTpdTLuyp9o3X7rnLT87SZEo= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2 h1:SZRVx928rbYZ6hEKUIN+vtGDkl7uotABRWGY4OAg5gM= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2/go.mod h1:ylS4c28ACSI59oJrOdW4pHS4n0Hw4TgSPHn8rpHl4Yw= +buf.build/gen/go/bufbuild/registry/connectrpc/go v1.16.2-20240801134127-09fbc17f7c9e.1 h1:IV4si5SvDJSGQ/kpcnmOFKDKh8erG6zPy+NhmxlYdxM= +buf.build/gen/go/bufbuild/registry/connectrpc/go v1.16.2-20240801134127-09fbc17f7c9e.1/go.mod h1:4isTSbIhQ6wERY99Kvds0UuOcFMUoPDBPZfaAKrUnSE= +buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.34.2-20240801134127-09fbc17f7c9e.2 h1:7fUEOBrfNd50BMAls2tLn9RhttbDIfxRXML99YaLqKY= +buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.34.2-20240801134127-09fbc17f7c9e.2/go.mod h1:psseUmlKRo9v5LZJtR/aTpdTLuyp9o3X7rnLT87SZEo= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= connectrpc.com/connect v1.16.2 h1:ybd6y+ls7GOlb7Bh5C8+ghA6SvCBajHwxssO2CGFjqE= connectrpc.com/connect v1.16.2/go.mod h1:n2kgwskMHXC+lVqb18wngEpF95ldBHXjZYJussz5FRc= -connectrpc.com/otelconnect v0.7.0 h1:ZH55ZZtcJOTKWWLy3qmL4Pam4RzRWBJFOqTPyAqCXkY= -connectrpc.com/otelconnect v0.7.0/go.mod h1:Bt2ivBymHZHqxvo4HkJ0EwHuUzQN6k2l0oH+mp/8nwc= +connectrpc.com/otelconnect v0.7.1 h1:scO5pOb0i4yUE66CnNrHeK1x51yq0bE0ehPg6WvzXJY= +connectrpc.com/otelconnect v0.7.1/go.mod h1:dh3bFgHBTb2bkqGCeVVOtHJreSns7uu9wwL2Tbz17ms= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/Microsoft/hcsshim v0.12.5 h1:bpTInLlDy/nDRWFVcefDZZ1+U8tS+rz3MxjKgu9boo0= +github.com/Microsoft/hcsshim v0.12.5/go.mod h1:tIUGego4G1EN5Hb6KC90aDYiUI2dqLSTTOCjVNpOgZ8= github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/bufbuild/protocompile v0.14.0 h1:z3DW4IvXE5G/uTOnSQn+qwQQxvhckkTWLS/0No/o7KU= github.com/bufbuild/protocompile v0.14.0/go.mod h1:N6J1NYzkspJo3ZwyL4Xjvli86XOj1xq4qAasUFxGups= github.com/bufbuild/protoplugin v0.0.0-20240323223605-e2735f6c31ee h1:E6ET8YUcYJ1lAe6ctR3as7yqzW2BNItDFnaB5zQq/8M= github.com/bufbuild/protoplugin v0.0.0-20240323223605-e2735f6c31ee/go.mod h1:HjGFxsck9RObrTJp2hXQZfWhPgZqnR6sR1U5fCA/Kus= -github.com/bufbuild/protovalidate-go v0.6.2 h1:U/V3CGF0kPlR12v41rjO4DrYZtLcS4ZONLmWN+rJVCQ= -github.com/bufbuild/protovalidate-go v0.6.2/go.mod h1:4BR3rKEJiUiTy+sqsusFn2ladOf0kYmA2Reo6BHSBgQ= -github.com/bufbuild/protoyaml-go v0.1.9 h1:anV5UtF1Mlvkkgp4NWA6U/zOnJFng8Orq4Vf3ZUQHBU= -github.com/bufbuild/protoyaml-go v0.1.9/go.mod h1:KCBItkvZOK/zwGueLdH1Wx1RLyFn5rCH7YjQrdty2Wc= -github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= -github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/bufbuild/protovalidate-go v0.6.4 h1:QtNIz4LGclM3UArQv/R1AKNF7MO8wriT9v7b8Gnmqak= +github.com/bufbuild/protovalidate-go v0.6.4/go.mod h1:HlkVnkE/zVYZvHIG/a7QZuzqC9bSqHaOOTeRomYF0Q8= +github.com/bufbuild/protoyaml-go v0.1.11 h1:Iyixd6Y5dx6ws6Uh8APgC1lMyvXt710NayoY8cY0Vj8= +github.com/bufbuild/protoyaml-go v0.1.11/go.mod h1:KCBItkvZOK/zwGueLdH1Wx1RLyFn5rCH7YjQrdty2Wc= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= github.com/chromedp/chromedp v0.9.2/go.mod h1:LkSXJKONWTCHAfQasKFUZI+mxqS4tZqhmtGzzhLsnLs= github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= @@ -33,39 +40,60 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0= +github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0= +github.com/containerd/containerd v1.7.20 h1:Sl6jQYk3TRavaU83h66QMbI2Nqg9Jm6qzwX57Vsn1SQ= +github.com/containerd/containerd v1.7.20/go.mod h1:52GsS5CwquuqPuLncsXwG0t2CiUce+KsNHJZQJvAgR0= +github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= +github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= +github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= +github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= +github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= +github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= github.com/containerd/stargz-snapshotter/estargz v0.15.1 h1:eXJjw9RbkLFgioVaTG+G/ZW/0kEe2oEKCdS/ZxIyoCU= github.com/containerd/stargz-snapshotter/estargz v0.15.1/go.mod h1:gr2RNwukQ/S9Nv33Lt6UC7xEx58C+LHRdoqbEKjz1Kk= +github.com/containerd/ttrpc v1.2.5 h1:IFckT1EFQoFBMG4c3sMdT8EP3/aKfumK1msY+Ze4oLU= +github.com/containerd/ttrpc v1.2.5/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o= +github.com/containerd/typeurl/v2 v2.2.0 h1:6NBDbQzr7I5LHgp34xAXYF5DOTQDn05X58lsPEmzLso= +github.com/containerd/typeurl/v2 v2.2.0/go.mod h1:8XOOxnyatxSWuG8OfsZXVnAF4iZfedjS/8UHSPJnX4g= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/cli v26.1.4+incompatible h1:I8PHdc0MtxEADqYJZvhBrW9bo8gawKwwenxRM7/rLu8= -github.com/docker/cli v26.1.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.1.2+incompatible h1:nYviRv5Y+YAKx3dFrTvS1ErkyVVunKOhoweCTE1BsnI= +github.com/docker/cli v27.1.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v27.0.0+incompatible h1:JRugTYuelmWlW0M3jakcIadDx2HUoUO6+Tf2C5jVfwA= -github.com/docker/docker v27.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.1.2+incompatible h1:AhGzR1xaQIy53qCkxARaFluI00WPGtXn0AJuoQsVYTY= +github.com/docker/docker v27.1.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6Uu2PdjCQwWCJ3bM= +github.com/envoyproxy/protoc-gen-validate v1.1.0/go.mod h1:sXRDRVmzEbkM7CVcM06s9shE/m23dg3wzjl0UWqJ2q4= github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= github.com/felixge/fgprof v0.9.4 h1:ocDNwMFlnA0NU0zSB3I52xkO4sFXk80VK9lXjLClu88= github.com/felixge/fgprof v0.9.4/go.mod h1:yKl+ERSa++RYOs32d8K6WEXCB4uXdLls4ZaZPpayhMM= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/go-chi/chi/v5 v5.0.14 h1:PyEwo2Vudraa0x/Wl6eDRRW2NXBvekgfxyydcM0WGE0= -github.com/go-chi/chi/v5 v5.0.14/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw= +github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -74,25 +102,49 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gofrs/uuid/v5 v5.2.0 h1:qw1GMx6/y8vhVsx626ImfKMuS5CvJmhIKKtuyvfajMM= -github.com/gofrs/uuid/v5 v5.2.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= +github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= +github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= +github.com/gofrs/uuid/v5 v5.3.0 h1:m0mUMr+oVYUdxpMLgSYCZiXe7PuVPnI94+OMeVBNedk= +github.com/gofrs/uuid/v5 v5.3.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/cel-go v0.20.1 h1:nDx9r8S3L4pE61eDdt8igGj8rf5kjYR3ILxWIpWNi84= -github.com/google/cel-go v0.20.1/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= +github.com/google/cel-go v0.21.0 h1:cl6uW/gxN+Hy50tNYvI691+sXxioCnstFzLp2WO4GCI= +github.com/google/cel-go v0.21.0/go.mod h1:rHUlWCcBKgyEk+eV03RPdZUekPp6YcJwV0FxuUksYxc= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-containerregistry v0.19.2 h1:TannFKE1QSajsP6hPWb5oJNgKe1IKjHukIKDUmvsV6w= -github.com/google/go-containerregistry v0.19.2/go.mod h1:YCMFNQeeXeLF+dnhhWkqDItx/JSkH01j1Kis4PsjzFI= +github.com/google/go-containerregistry v0.20.2 h1:B1wPJ1SN/S7pB+ZAimcciVD+r+yV/l/DSArMxlbwseo= +github.com/google/go-containerregistry v0.20.2/go.mod h1:z38EKdKh4h7IP2gSfUUqEvalZBqs6AoLeWfUy34nQC8= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= -github.com/google/pprof v0.0.0-20240622144329-c177fd99eaa9 h1:ouFdLLCOyCfnxGpQTMZKHLyHr/D1GFbQzEsJxumO16E= -github.com/google/pprof v0.0.0-20240622144329-c177fd99eaa9/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -118,6 +170,20 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= +github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= +github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= +github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= +github.com/moby/sys/mount v0.3.4 h1:yn5jq4STPztkkzSKpZkLcmjue+bZJ0u2AuQY1iNI1Ww= +github.com/moby/sys/mount v0.3.4/go.mod h1:KcQJMbQdJHPlq5lcYT+/CjatWM4PuxKe+XLSVS4J6Os= +github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg= +github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4= +github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU= +github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko= +github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo= +github.com/moby/sys/user v0.3.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs= +github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= +github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= @@ -126,19 +192,24 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= +github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaLpt7tQ7oU= +github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA= github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po= github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= @@ -164,25 +235,30 @@ github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinC github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 h1:t6wl9SPayj+c7lEIFgm4ooDBZVb01IhLB4InpomhRw8= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg= +go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= +go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= +go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= +go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= +go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= go.opentelemetry.io/otel/sdk/metric v1.19.0 h1:EJoTO5qysMsYCa+w4UghwFV/ptQgqSL/8Ni+hx+8i1k= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= -go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= +go.opentelemetry.io/otel/sdk/metric v1.19.0/go.mod h1:XjG0jQyFJrv2PbMvwND7LwCEhsJzCzV5210euduKcKY= +go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= +go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= @@ -190,25 +266,38 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= -golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= -golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -218,35 +307,64 @@ golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= +golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= -golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 h1:MuYw1wJzT+ZkybKfaOXKp5hJiZDn2iHaXRw0mRYdHSc= -google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4/go.mod h1:px9SlOOZBg1wM1zdnr8jEL4CNGUBZ+ZKYtNPApNQc4c= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 h1:Di6ANFilr+S60a4S61ZM00vLdw0IrQOSMS2/6mrnOU0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= -google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= +gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/make/buf/all.mk b/make/buf/all.mk index 26a4eba592..7cc70fbc6a 100644 --- a/make/buf/all.mk +++ b/make/buf/all.mk @@ -1,12 +1,6 @@ GO_ALL_REPO_PKGS := ./cmd/... ./private/... -# TODO: Remove go-winio v0.6.1 and otel v1.24.0 when we no longer need to support Golang <1.21 # TODO: Remove antlr when we no longer need Golang <1.22 GO_GET_PKGS := $(GO_GET_PKGS) \ - github.com/Microsoft/go-winio@v0.6.1 \ - go.opentelemetry.io/otel@v1.24.0 \ - go.opentelemetry.io/otel/sdk@v1.24.0 \ - go.opentelemetry.io/otel/trace@v1.24.0 \ - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp@v1.24.0 \ github.com/antlr4-go/antlr/v4@v4.13.0 GO_BINS := $(GO_BINS) \ cmd/buf \ @@ -27,7 +21,7 @@ GO_TEST_BINS := $(GO_TEST_BINS) \ private/buf/cmd/buf/command/alpha/protoc/internal/protoc-gen-insertion-point-receiver \ private/buf/cmd/buf/command/alpha/protoc/internal/protoc-gen-insertion-point-writer \ private/buf/cmd/buf/command/generate/internal/protoc-gen-top-level-type-names-yaml -GO_MOD_VERSION := 1.20 +GO_MOD_VERSION := 1.21 DOCKER_BINS := $(DOCKER_BINS) buf FILE_IGNORES := $(FILE_IGNORES) \ .build/ \ diff --git a/make/go/dep_golangci_lint.mk b/make/go/dep_golangci_lint.mk index 82e051221a..2786ea075e 100644 --- a/make/go/dep_golangci_lint.mk +++ b/make/go/dep_golangci_lint.mk @@ -7,9 +7,9 @@ $(call _assert_var,CACHE_VERSIONS) $(call _assert_var,CACHE_BIN) # Settable -# https://github.com/golangci/golangci-lint/releases 20240526 checked 20240527 +# https://github.com/golangci/golangci-lint/releases 20240813 checked 20240813 # Contrast golangci-lint configuration with the one in https://github.com/connectrpc/connect-go/blob/main/.golangci.yml when upgrading -GOLANGCI_LINT_VERSION ?= v1.59.0 +GOLANGCI_LINT_VERSION ?= v1.60.1 GOLANGCI_LINT := $(CACHE_VERSIONS)/golangci-lint/$(GOLANGCI_LINT_VERSION) $(GOLANGCI_LINT): diff --git a/make/go/go.mk b/make/go/go.mk index b0d57276fd..503d72a53b 100644 --- a/make/go/go.mk +++ b/make/go/go.mk @@ -18,7 +18,9 @@ GO_TEST_BINS ?= # Settable GO_GET_PKGS ?= # Settable -GO_MOD_VERSION ?= 1.20 +GO_MOD_VERSION ?= 1.21 +# Settable +GO_MOD_TOOLCHAIN ?= 1.23.0 # Settable GO_ALL_REPO_PKGS ?= ./cmd/... ./internal/... # Settable @@ -70,6 +72,7 @@ upgradegodeps: rm -f go.mod go.sum go mod init $(GO_MODULE) go mod edit -go=$(GO_MOD_VERSION) + go mod edit -toolchain=go$(GO_MOD_TOOLCHAIN) ifneq ($(GO_GET_PKGS),) go get $(GO_GET_PKGS) endif diff --git a/private/buf/bufcli/bufcli.go b/private/buf/bufcli/bufcli.go index 37286ebc43..969fcb2009 100644 --- a/private/buf/bufcli/bufcli.go +++ b/private/buf/bufcli/bufcli.go @@ -15,4 +15,4 @@ package bufcli // Version is the CLI version of buf. -const Version = "1.36.1-dev" +const Version = "1.37.1-dev" diff --git a/private/buf/bufcli/rules.go b/private/buf/bufcli/rules.go new file mode 100644 index 0000000000..cfbdcd4b9d --- /dev/null +++ b/private/buf/bufcli/rules.go @@ -0,0 +1,45 @@ +// Copyright 2020-2024 Buf Technologies, Inc. +// +// 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. + +package bufcli + +import ( + "fmt" + "io" + "strings" + + "github.com/bufbuild/buf/private/bufpkg/bufcheck" +) + +// AllRuleFormatStrings is all rule format strings. +var AllRuleFormatStrings = []string{ + "text", + "json", +} + +// PrintRules prints the Rules to the writer given the --format and --include-deprecated flag values. +func PrintRules(writer io.Writer, rules []bufcheck.Rule, format string, includeDeprecated bool) error { + var printRulesOptions []bufcheck.PrintRulesOption + switch s := strings.ToLower(strings.TrimSpace(format)); s { + case "", "text": + case "json": + printRulesOptions = append(printRulesOptions, bufcheck.PrintRulesWithJSON()) + default: + return fmt.Errorf("unknown format: %q", s) + } + if includeDeprecated { + printRulesOptions = append(printRulesOptions, bufcheck.PrintRulesWithDeprecated()) + } + return bufcheck.PrintRules(writer, rules, printRulesOptions...) +} diff --git a/private/buf/bufcurl/tls.go b/private/buf/bufcurl/tls.go index ef232bdd25..a86d10c0fd 100644 --- a/private/buf/bufcurl/tls.go +++ b/private/buf/bufcurl/tls.go @@ -52,7 +52,7 @@ func MakeVerboseTLSConfig(settings *TLSSettings, authority string, printer verbo // we verify manually so that we can emit verbose output while doing so conf.InsecureSkipVerify = true conf.VerifyConnection = func(state tls.ConnectionState) error { - printer.Printf("* TLS connection using %s / %s", tlsVersionName(state.Version), tls.CipherSuiteName(state.CipherSuite)) + printer.Printf("* TLS connection using %s / %s", tls.VersionName(state.Version), tls.CipherSuiteName(state.CipherSuite)) if state.DidResume { printer.Printf("* (TLS session resumed)") } diff --git a/private/buf/bufcurl/tls_version_name_go120.go b/private/buf/bufcurl/tls_version_name_go120.go deleted file mode 100644 index 8021a30d97..0000000000 --- a/private/buf/bufcurl/tls_version_name_go120.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2020-2024 Buf Technologies, Inc. -// -// 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. - -//go:build !go1.21 - -package bufcurl - -import "crypto/tls" - -func tlsVersionName(tlsVersion uint16) string { - // TODO: once we can use Go 1.21, it will provide tls.VersionName that we can use - // https://github.com/golang/go/issues/46308 - switch tlsVersion { - case tls.VersionTLS10: - return "TLSv1.0" - case tls.VersionTLS11: - return "TLSv1.1" - case tls.VersionTLS12: - return "TLSv1.2" - case tls.VersionTLS13: - return "TLSv1.3" - default: - return "(unrecognized TLS version)" - } -} diff --git a/private/buf/bufcurl/tls_version_name_go121.go b/private/buf/bufcurl/tls_version_name_go121.go deleted file mode 100644 index f4b3359cb9..0000000000 --- a/private/buf/bufcurl/tls_version_name_go121.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2020-2024 Buf Technologies, Inc. -// -// 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. - -//go:build go1.21 - -package bufcurl - -import "crypto/tls" - -func tlsVersionName(tlsVersion uint16) string { - return tls.VersionName(tlsVersion) -} diff --git a/private/buf/bufgen/generator.go b/private/buf/bufgen/generator.go index 375420a4f0..44cc6cea97 100644 --- a/private/buf/bufgen/generator.go +++ b/private/buf/bufgen/generator.go @@ -295,12 +295,10 @@ func (g *generator) execPlugins( // out: gen/proto // - name: insertion-point-writer // out: gen/proto - ctx, cancel := context.WithCancel(ctx) - defer cancel() if err := thread.Parallelize( ctx, jobs, - thread.ParallelizeWithCancel(cancel), + thread.ParallelizeWithCancelOnFailure(), ); err != nil { if errs := multierr.Errors(err); len(errs) > 0 { return nil, errs[0] diff --git a/private/buf/bufworkspace/workspace_targeting.go b/private/buf/bufworkspace/workspace_targeting.go index 86787024c0..88315306eb 100644 --- a/private/buf/bufworkspace/workspace_targeting.go +++ b/private/buf/bufworkspace/workspace_targeting.go @@ -562,10 +562,18 @@ func getMappedModuleBucketAndModuleTargeting( ), ) } + docStorageReadBucket, err := bufmodule.GetDocStorageReadBucket(ctx, moduleBucket) + if err != nil { + return nil, nil, err + } + licenseStorageReadBucket, err := bufmodule.GetLicenseStorageReadBucket(ctx, moduleBucket) + if err != nil { + return nil, nil, err + } rootBuckets = append( rootBuckets, - bufmodule.GetDocStorageReadBucket(ctx, moduleBucket), - bufmodule.GetLicenseStorageReadBucket(moduleBucket), + docStorageReadBucket, + licenseStorageReadBucket, ) mappedModuleBucket := storage.MultiReadBucket(rootBuckets...) moduleTargeting, err := newModuleTargeting( diff --git a/private/buf/cmd/buf/buf_test.go b/private/buf/cmd/buf/buf_test.go index 62f79912f0..d0b0e94854 100644 --- a/private/buf/cmd/buf/buf_test.go +++ b/private/buf/cmd/buf/buf_test.go @@ -665,52 +665,53 @@ ENUM_FIRST_VALUE_ZERO OTHER Ch func TestCheckLsLintRulesV2(t *testing.T) { t.Parallel() expectedStdout := ` -ID CATEGORIES PURPOSE -DIRECTORY_SAME_PACKAGE MINIMAL, BASIC, DEFAULT Checks that all files in a given directory are in the same package. -PACKAGE_DEFINED MINIMAL, BASIC, DEFAULT Checks that all files have a package defined. -PACKAGE_DIRECTORY_MATCH MINIMAL, BASIC, DEFAULT Checks that all files are in a directory that matches their package name. -PACKAGE_NO_IMPORT_CYCLE MINIMAL, BASIC, DEFAULT Checks that packages do not have import cycles. -PACKAGE_SAME_DIRECTORY MINIMAL, BASIC, DEFAULT Checks that all files with a given package are in the same directory. -ENUM_FIRST_VALUE_ZERO BASIC, DEFAULT Checks that all first values of enums have a numeric value of 0. -ENUM_NO_ALLOW_ALIAS BASIC, DEFAULT Checks that enums do not have the allow_alias option set. -ENUM_PASCAL_CASE BASIC, DEFAULT Checks that enums are PascalCase. -ENUM_VALUE_UPPER_SNAKE_CASE BASIC, DEFAULT Checks that enum values are UPPER_SNAKE_CASE. -FIELD_LOWER_SNAKE_CASE BASIC, DEFAULT Checks that field names are lower_snake_case. -FIELD_NOT_REQUIRED BASIC, DEFAULT Checks that fields are not configured to be required. -IMPORT_NO_PUBLIC BASIC, DEFAULT Checks that imports are not public. -IMPORT_NO_WEAK BASIC, DEFAULT Checks that imports are not weak. -IMPORT_USED BASIC, DEFAULT Checks that imports are used. -MESSAGE_PASCAL_CASE BASIC, DEFAULT Checks that messages are PascalCase. -ONEOF_LOWER_SNAKE_CASE BASIC, DEFAULT Checks that oneof names are lower_snake_case. -PACKAGE_LOWER_SNAKE_CASE BASIC, DEFAULT Checks that packages are lower_snake.case. -PACKAGE_SAME_CSHARP_NAMESPACE BASIC, DEFAULT Checks that all files with a given package have the same value for the csharp_namespace option. -PACKAGE_SAME_GO_PACKAGE BASIC, DEFAULT Checks that all files with a given package have the same value for the go_package option. -PACKAGE_SAME_JAVA_MULTIPLE_FILES BASIC, DEFAULT Checks that all files with a given package have the same value for the java_multiple_files option. -PACKAGE_SAME_JAVA_PACKAGE BASIC, DEFAULT Checks that all files with a given package have the same value for the java_package option. -PACKAGE_SAME_PHP_NAMESPACE BASIC, DEFAULT Checks that all files with a given package have the same value for the php_namespace option. -PACKAGE_SAME_RUBY_PACKAGE BASIC, DEFAULT Checks that all files with a given package have the same value for the ruby_package option. -PACKAGE_SAME_SWIFT_PREFIX BASIC, DEFAULT Checks that all files with a given package have the same value for the swift_prefix option. -RPC_PASCAL_CASE BASIC, DEFAULT Checks that RPCs are PascalCase. -SERVICE_PASCAL_CASE BASIC, DEFAULT Checks that services are PascalCase. -SYNTAX_SPECIFIED BASIC, DEFAULT Checks that all files have a syntax specified. -ENUM_VALUE_PREFIX DEFAULT Checks that enum values are prefixed with ENUM_NAME_UPPER_SNAKE_CASE. -ENUM_ZERO_VALUE_SUFFIX DEFAULT Checks that enum zero values have a consistent suffix (configurable, default suffix is "_UNSPECIFIED"). -FILE_LOWER_SNAKE_CASE DEFAULT Checks that filenames are lower_snake_case. -PACKAGE_VERSION_SUFFIX DEFAULT Checks that the last component of all packages is a version of the form v\d+, v\d+test.*, v\d+(alpha|beta)\d+, or v\d+p\d+(alpha|beta)\d+, where numbers are >=1. -PROTOVALIDATE DEFAULT Checks that protovalidate rules are valid and all CEL expressions compile. -RPC_REQUEST_RESPONSE_UNIQUE DEFAULT Checks that RPC request and response types are only used in one RPC (configurable). -RPC_REQUEST_STANDARD_NAME DEFAULT Checks that RPC request type names are RPCNameRequest or ServiceNameRPCNameRequest (configurable). -RPC_RESPONSE_STANDARD_NAME DEFAULT Checks that RPC response type names are RPCNameResponse or ServiceNameRPCNameResponse (configurable). -SERVICE_SUFFIX DEFAULT Checks that services have a consistent suffix (configurable, default suffix is "Service"). -COMMENT_ENUM COMMENTS Checks that enums have non-empty comments. -COMMENT_ENUM_VALUE COMMENTS Checks that enum values have non-empty comments. -COMMENT_FIELD COMMENTS Checks that fields have non-empty comments. -COMMENT_MESSAGE COMMENTS Checks that messages have non-empty comments. -COMMENT_ONEOF COMMENTS Checks that oneof have non-empty comments. -COMMENT_RPC COMMENTS Checks that RPCs have non-empty comments. -COMMENT_SERVICE COMMENTS Checks that services have non-empty comments. -RPC_NO_CLIENT_STREAMING UNARY_RPC Checks that RPCs are not client streaming. -RPC_NO_SERVER_STREAMING UNARY_RPC Checks that RPCs are not server streaming. +ID CATEGORIES PURPOSE +DIRECTORY_SAME_PACKAGE MINIMAL, BASIC, DEFAULT Checks that all files in a given directory are in the same package. +PACKAGE_DEFINED MINIMAL, BASIC, DEFAULT Checks that all files have a package defined. +PACKAGE_DIRECTORY_MATCH MINIMAL, BASIC, DEFAULT Checks that all files are in a directory that matches their package name. +PACKAGE_NO_IMPORT_CYCLE MINIMAL, BASIC, DEFAULT Checks that packages do not have import cycles. +PACKAGE_SAME_DIRECTORY MINIMAL, BASIC, DEFAULT Checks that all files with a given package are in the same directory. +ENUM_FIRST_VALUE_ZERO BASIC, DEFAULT Checks that all first values of enums have a numeric value of 0. +ENUM_NO_ALLOW_ALIAS BASIC, DEFAULT Checks that enums do not have the allow_alias option set. +ENUM_PASCAL_CASE BASIC, DEFAULT Checks that enums are PascalCase. +ENUM_VALUE_UPPER_SNAKE_CASE BASIC, DEFAULT Checks that enum values are UPPER_SNAKE_CASE. +FIELD_LOWER_SNAKE_CASE BASIC, DEFAULT Checks that field names are lower_snake_case. +FIELD_NOT_REQUIRED BASIC, DEFAULT Checks that fields are not configured to be required. +IMPORT_NO_PUBLIC BASIC, DEFAULT Checks that imports are not public. +IMPORT_NO_WEAK BASIC, DEFAULT Checks that imports are not weak. +IMPORT_USED BASIC, DEFAULT Checks that imports are used. +MESSAGE_PASCAL_CASE BASIC, DEFAULT Checks that messages are PascalCase. +ONEOF_LOWER_SNAKE_CASE BASIC, DEFAULT Checks that oneof names are lower_snake_case. +PACKAGE_LOWER_SNAKE_CASE BASIC, DEFAULT Checks that packages are lower_snake.case. +PACKAGE_SAME_CSHARP_NAMESPACE BASIC, DEFAULT Checks that all files with a given package have the same value for the csharp_namespace option. +PACKAGE_SAME_GO_PACKAGE BASIC, DEFAULT Checks that all files with a given package have the same value for the go_package option. +PACKAGE_SAME_JAVA_MULTIPLE_FILES BASIC, DEFAULT Checks that all files with a given package have the same value for the java_multiple_files option. +PACKAGE_SAME_JAVA_PACKAGE BASIC, DEFAULT Checks that all files with a given package have the same value for the java_package option. +PACKAGE_SAME_PHP_NAMESPACE BASIC, DEFAULT Checks that all files with a given package have the same value for the php_namespace option. +PACKAGE_SAME_RUBY_PACKAGE BASIC, DEFAULT Checks that all files with a given package have the same value for the ruby_package option. +PACKAGE_SAME_SWIFT_PREFIX BASIC, DEFAULT Checks that all files with a given package have the same value for the swift_prefix option. +RPC_PASCAL_CASE BASIC, DEFAULT Checks that RPCs are PascalCase. +SERVICE_PASCAL_CASE BASIC, DEFAULT Checks that services are PascalCase. +SYNTAX_SPECIFIED BASIC, DEFAULT Checks that all files have a syntax specified. +ENUM_VALUE_PREFIX DEFAULT Checks that enum values are prefixed with ENUM_NAME_UPPER_SNAKE_CASE. +ENUM_ZERO_VALUE_SUFFIX DEFAULT Checks that enum zero values have a consistent suffix (configurable, default suffix is "_UNSPECIFIED"). +FILE_LOWER_SNAKE_CASE DEFAULT Checks that filenames are lower_snake_case. +PACKAGE_VERSION_SUFFIX DEFAULT Checks that the last component of all packages is a version of the form v\d+, v\d+test.*, v\d+(alpha|beta)\d+, or v\d+p\d+(alpha|beta)\d+, where numbers are >=1. +PROTOVALIDATE DEFAULT Checks that protovalidate rules are valid and all CEL expressions compile. +RPC_REQUEST_RESPONSE_UNIQUE DEFAULT Checks that RPC request and response types are only used in one RPC (configurable). +RPC_REQUEST_STANDARD_NAME DEFAULT Checks that RPC request type names are RPCNameRequest or ServiceNameRPCNameRequest (configurable). +RPC_RESPONSE_STANDARD_NAME DEFAULT Checks that RPC response type names are RPCNameResponse or ServiceNameRPCNameResponse (configurable). +SERVICE_SUFFIX DEFAULT Checks that services have a consistent suffix (configurable, default suffix is "Service"). +COMMENT_ENUM COMMENTS Checks that enums have non-empty comments. +COMMENT_ENUM_VALUE COMMENTS Checks that enum values have non-empty comments. +COMMENT_FIELD COMMENTS Checks that fields have non-empty comments. +COMMENT_MESSAGE COMMENTS Checks that messages have non-empty comments. +COMMENT_ONEOF COMMENTS Checks that oneof have non-empty comments. +COMMENT_RPC COMMENTS Checks that RPCs have non-empty comments. +COMMENT_SERVICE COMMENTS Checks that services have non-empty comments. +RPC_NO_CLIENT_STREAMING UNARY_RPC Checks that RPCs are not client streaming. +RPC_NO_SERVER_STREAMING UNARY_RPC Checks that RPCs are not server streaming. +STABLE_PACKAGE_NO_IMPORT_UNSTABLE Checks that all files that have stable versioned packages do not import packages with unstable version packages. ` testRunStdout( t, diff --git a/private/buf/cmd/buf/command/alpha/registry/token/tokenget/tokenget.go b/private/buf/cmd/buf/command/alpha/registry/token/tokenget/tokenget.go index 0e958d6d67..5f8a7af1f2 100644 --- a/private/buf/cmd/buf/command/alpha/registry/token/tokenget/tokenget.go +++ b/private/buf/cmd/buf/command/alpha/registry/token/tokenget/tokenget.go @@ -92,7 +92,7 @@ func run( } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/alpha/registry/token/tokenlist/tokenlist.go b/private/buf/cmd/buf/command/alpha/registry/token/tokenlist/tokenlist.go index cc887cd1e7..af8f7b79f3 100644 --- a/private/buf/cmd/buf/command/alpha/registry/token/tokenlist/tokenlist.go +++ b/private/buf/cmd/buf/command/alpha/registry/token/tokenlist/tokenlist.go @@ -104,7 +104,7 @@ func run( } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete/plugindelete.go b/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete/plugindelete.go index 14cf515edd..1cb902872b 100644 --- a/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete/plugindelete.go +++ b/private/buf/cmd/buf/command/beta/registry/plugin/plugindelete/plugindelete.go @@ -66,11 +66,11 @@ func run( identity, version, _ := strings.Cut(container.Arg(0), ":") pluginIdentity, err := bufremotepluginref.PluginIdentityForString(identity) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } if version != "" { if err := bufremotepluginref.ValidatePluginVersion(version); err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } } clientConfig, err := bufcli.NewConnectClientConfig(container) diff --git a/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/pluginpush.go b/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/pluginpush.go index 7cd964198e..c4c5ad6529 100644 --- a/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/pluginpush.go +++ b/private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/pluginpush.go @@ -140,7 +140,7 @@ func run( } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } source, err := bufcli.GetInputValue(container, "" /* The input hashtag is not supported here */, ".") if err != nil { diff --git a/private/buf/cmd/buf/command/beta/stats/stats.go b/private/buf/cmd/buf/command/beta/stats/stats.go index d62d7cb25d..b599de10c2 100644 --- a/private/buf/cmd/buf/command/beta/stats/stats.go +++ b/private/buf/cmd/buf/command/beta/stats/stats.go @@ -84,7 +84,7 @@ func run( ) error { format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } input, err := bufcli.GetInputValue(container, flags.InputHashtag, ".") if err != nil { diff --git a/private/buf/cmd/buf/command/config/internal/internal.go b/private/buf/cmd/buf/command/config/internal/internal.go index f7dd434d47..55d5a89470 100644 --- a/private/buf/cmd/buf/command/config/internal/internal.go +++ b/private/buf/cmd/buf/command/config/internal/internal.go @@ -118,7 +118,7 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) { "text", fmt.Sprintf( "The format to print rules as. Must be one of %s", - stringutil.SliceToString(bufcheck.AllRuleFormatStrings), + stringutil.SliceToString(bufcli.AllRuleFormatStrings), ), ) flagSet.StringVar( @@ -249,7 +249,7 @@ func lsRun( return syserror.Newf("unknown FileVersion: %v", fileVersion) } } - return bufcheck.PrintRules( + return bufcli.PrintRules( container.Stdout(), rules, flags.Format, diff --git a/private/buf/cmd/buf/command/curl/curl.go b/private/buf/cmd/buf/command/curl/curl.go index a5ab95688d..f0480c3ccc 100644 --- a/private/buf/cmd/buf/command/curl/curl.go +++ b/private/buf/cmd/buf/command/curl/curl.go @@ -29,6 +29,7 @@ import ( "path/filepath" "sort" "strings" + "sync" "time" "connectrpc.com/connect" @@ -39,7 +40,6 @@ import ( "github.com/bufbuild/buf/private/pkg/app/appext" "github.com/bufbuild/buf/private/pkg/netrc" "github.com/bufbuild/buf/private/pkg/stringutil" - "github.com/bufbuild/buf/private/pkg/syncext" "github.com/bufbuild/buf/private/pkg/verbose" "github.com/spf13/pflag" "go.uber.org/multierr" @@ -906,7 +906,7 @@ func run(ctx context.Context, container appext.Container, f *flags) (err error) } }() - makeTransportOnce := syncext.OnceValues(func() (connect.HTTPClient, error) { + makeTransportOnce := sync.OnceValues(func() (connect.HTTPClient, error) { // We do this lazily since some commands don't need a transport, like listing // services and methods and describing elements when the schema source is // something other than server reflection. We memoize the result to use the diff --git a/private/buf/cmd/buf/command/mod/internal/internal.go b/private/buf/cmd/buf/command/mod/internal/internal.go index baafa7f60e..cf5f1d5d57 100644 --- a/private/buf/cmd/buf/command/mod/internal/internal.go +++ b/private/buf/cmd/buf/command/mod/internal/internal.go @@ -116,7 +116,7 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) { "text", fmt.Sprintf( "The format to print rules as. Must be one of %s", - stringutil.SliceToString(bufcheck.AllRuleFormatStrings), + stringutil.SliceToString(bufcli.AllRuleFormatStrings), ), ) flagSet.StringVar( @@ -207,7 +207,7 @@ func lsRun( return syserror.Newf("unknown FileVersion: %v", fileVersion) } } - return bufcheck.PrintRules( + return bufcli.PrintRules( container.Stdout(), rules, flags.Format, diff --git a/private/buf/cmd/buf/command/push/push.go b/private/buf/cmd/buf/command/push/push.go index 45357b41f2..a16dc87ea8 100644 --- a/private/buf/cmd/buf/command/push/push.go +++ b/private/buf/cmd/buf/command/push/push.go @@ -333,7 +333,7 @@ func validateCreateFlags(flags *flags) error { ) } if _, err := bufmodule.ParseModuleVisibility(flags.CreateVisibility); err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } } else { if flags.CreateDefaultLabel != "" { diff --git a/private/buf/cmd/buf/command/registry/commit/commitaddlabel/commitaddlabel.go b/private/buf/cmd/buf/command/registry/commit/commitaddlabel/commitaddlabel.go index 73f5783299..d58e881061 100644 --- a/private/buf/cmd/buf/command/registry/commit/commitaddlabel/commitaddlabel.go +++ b/private/buf/cmd/buf/command/registry/commit/commitaddlabel/commitaddlabel.go @@ -86,7 +86,7 @@ func run( ) error { moduleRef, err := bufmodule.ParseModuleRef(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } if moduleRef.Ref() == "" { return appcmd.NewInvalidArgumentError("commit is required") @@ -101,7 +101,7 @@ func run( } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/registry/commit/commitinfo/commitinfo.go b/private/buf/cmd/buf/command/registry/commit/commitinfo/commitinfo.go index c8bf35c75d..9ddacb363b 100644 --- a/private/buf/cmd/buf/command/registry/commit/commitinfo/commitinfo.go +++ b/private/buf/cmd/buf/command/registry/commit/commitinfo/commitinfo.go @@ -76,7 +76,7 @@ func run( ) error { moduleRef, err := bufmodule.ParseModuleRef(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } if moduleRef.Ref() == "" { return appcmd.NewInvalidArgumentErrorf("%q does not have a commit specified", moduleRef.String()) @@ -87,7 +87,7 @@ func run( } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) diff --git a/private/buf/cmd/buf/command/registry/commit/commitlist/commitlist.go b/private/buf/cmd/buf/command/registry/commit/commitlist/commitlist.go index 0e5a9e0785..84918d2959 100644 --- a/private/buf/cmd/buf/command/registry/commit/commitlist/commitlist.go +++ b/private/buf/cmd/buf/command/registry/commit/commitlist/commitlist.go @@ -106,11 +106,11 @@ func run( ) error { moduleRef, err := bufmodule.ParseModuleRef(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/registry/commit/commitresolve/commitresolve.go b/private/buf/cmd/buf/command/registry/commit/commitresolve/commitresolve.go index d030c3b716..e879e390d0 100644 --- a/private/buf/cmd/buf/command/registry/commit/commitresolve/commitresolve.go +++ b/private/buf/cmd/buf/command/registry/commit/commitresolve/commitresolve.go @@ -75,11 +75,11 @@ func run( ) error { moduleRef, err := bufmodule.ParseModuleRef(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) diff --git a/private/buf/cmd/buf/command/registry/label/labelarchive/labelarchive.go b/private/buf/cmd/buf/command/registry/label/labelarchive/labelarchive.go index d480e59608..449a75dd23 100644 --- a/private/buf/cmd/buf/command/registry/label/labelarchive/labelarchive.go +++ b/private/buf/cmd/buf/command/registry/label/labelarchive/labelarchive.go @@ -64,7 +64,7 @@ func run( ) error { moduleRef, err := bufmodule.ParseModuleRef(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } labelName := moduleRef.Ref() if labelName == "" { diff --git a/private/buf/cmd/buf/command/registry/label/labelinfo/labelinfo.go b/private/buf/cmd/buf/command/registry/label/labelinfo/labelinfo.go index 08cbb57fa9..ad485604b8 100644 --- a/private/buf/cmd/buf/command/registry/label/labelinfo/labelinfo.go +++ b/private/buf/cmd/buf/command/registry/label/labelinfo/labelinfo.go @@ -75,7 +75,7 @@ func run( ) error { moduleRef, err := bufmodule.ParseModuleRef(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } labelName := moduleRef.Ref() if labelName == "" { @@ -83,7 +83,7 @@ func run( } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/registry/label/labellist/labellist.go b/private/buf/cmd/buf/command/registry/label/labellist/labellist.go index b2746674f9..263f67275f 100644 --- a/private/buf/cmd/buf/command/registry/label/labellist/labellist.go +++ b/private/buf/cmd/buf/command/registry/label/labellist/labellist.go @@ -105,15 +105,15 @@ func run( ) error { moduleRef, err := bufmodule.ParseModuleRef(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } archiveStatusFitler, err := bufcli.ArchiveStatusFlagToArchiveStatusFilter(flags.ArchiveStatus) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/registry/label/labelunarchive/labelunarchive.go b/private/buf/cmd/buf/command/registry/label/labelunarchive/labelunarchive.go index 49655f9be6..9a17475cb9 100644 --- a/private/buf/cmd/buf/command/registry/label/labelunarchive/labelunarchive.go +++ b/private/buf/cmd/buf/command/registry/label/labelunarchive/labelunarchive.go @@ -64,7 +64,7 @@ func run( ) error { moduleRef, err := bufmodule.ParseModuleRef(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } labelName := moduleRef.Ref() if labelName == "" { diff --git a/private/buf/cmd/buf/command/registry/module/modulecreate/modulecreate.go b/private/buf/cmd/buf/command/registry/module/modulecreate/modulecreate.go index 2f78b27969..4ccf3aa352 100644 --- a/private/buf/cmd/buf/command/registry/module/modulecreate/modulecreate.go +++ b/private/buf/cmd/buf/command/registry/module/modulecreate/modulecreate.go @@ -91,15 +91,15 @@ func run( ) error { moduleFullName, err := bufmodule.ParseModuleFullName(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } visibility, err := bufcli.VisibilityFlagToVisibilityAllowUnspecified(flags.Visibility) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) diff --git a/private/buf/cmd/buf/command/registry/module/moduledelete/moduledelete.go b/private/buf/cmd/buf/command/registry/module/moduledelete/moduledelete.go index 54712317ed..fc08e5bd4a 100644 --- a/private/buf/cmd/buf/command/registry/module/moduledelete/moduledelete.go +++ b/private/buf/cmd/buf/command/registry/module/moduledelete/moduledelete.go @@ -74,7 +74,7 @@ func run( ) error { moduleFullName, err := bufmodule.ParseModuleFullName(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/registry/module/moduledeprecate/moduledeprecate.go b/private/buf/cmd/buf/command/registry/module/moduledeprecate/moduledeprecate.go index dcc321d1e4..33d004e1b8 100644 --- a/private/buf/cmd/buf/command/registry/module/moduledeprecate/moduledeprecate.go +++ b/private/buf/cmd/buf/command/registry/module/moduledeprecate/moduledeprecate.go @@ -56,7 +56,7 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) {} func run(ctx context.Context, container appext.Container, flags *flags) error { moduleFullName, err := bufmodule.ParseModuleFullName(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/registry/module/moduleinfo/moduleinfo.go b/private/buf/cmd/buf/command/registry/module/moduleinfo/moduleinfo.go index 439856af2d..58d2648b8a 100644 --- a/private/buf/cmd/buf/command/registry/module/moduleinfo/moduleinfo.go +++ b/private/buf/cmd/buf/command/registry/module/moduleinfo/moduleinfo.go @@ -75,11 +75,11 @@ func run( ) error { moduleFullName, err := bufmodule.ParseModuleFullName(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) diff --git a/private/buf/cmd/buf/command/registry/module/moduleundeprecate/moduleundeprecate.go b/private/buf/cmd/buf/command/registry/module/moduleundeprecate/moduleundeprecate.go index cbee2bc324..361a5b739a 100644 --- a/private/buf/cmd/buf/command/registry/module/moduleundeprecate/moduleundeprecate.go +++ b/private/buf/cmd/buf/command/registry/module/moduleundeprecate/moduleundeprecate.go @@ -41,7 +41,7 @@ func NewCommand(name string, builder appext.SubCommandBuilder) *appcmd.Command { func run(ctx context.Context, container appext.Container) error { moduleFullName, err := bufmodule.ParseModuleFullName(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/registry/module/moduleupdate/moduleupdate.go b/private/buf/cmd/buf/command/registry/module/moduleupdate/moduleupdate.go index e9abb54eb4..b2e6dd5974 100644 --- a/private/buf/cmd/buf/command/registry/module/moduleupdate/moduleupdate.go +++ b/private/buf/cmd/buf/command/registry/module/moduleupdate/moduleupdate.go @@ -92,11 +92,11 @@ func run( ) error { moduleFullName, err := bufmodule.ParseModuleFullName(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } visibility, err := bufcli.VisibilityFlagToVisibilityAllowUnspecified(flags.Visibility) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/registry/organization/organizationcreate/organizationcreate.go b/private/buf/cmd/buf/command/registry/organization/organizationcreate/organizationcreate.go index 8824c331f6..01cb3a3d4c 100644 --- a/private/buf/cmd/buf/command/registry/organization/organizationcreate/organizationcreate.go +++ b/private/buf/cmd/buf/command/registry/organization/organizationcreate/organizationcreate.go @@ -74,11 +74,11 @@ func run( ) error { moduleOwner, err := bufcli.ParseModuleOwner(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) diff --git a/private/buf/cmd/buf/command/registry/organization/organizationdelete/organizationdelete.go b/private/buf/cmd/buf/command/registry/organization/organizationdelete/organizationdelete.go index 03b0818e55..9a0e4e6ca6 100644 --- a/private/buf/cmd/buf/command/registry/organization/organizationdelete/organizationdelete.go +++ b/private/buf/cmd/buf/command/registry/organization/organizationdelete/organizationdelete.go @@ -73,7 +73,7 @@ func run( ) error { moduleOwner, err := bufcli.ParseModuleOwner(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } if !flags.Force { if err := bufcli.PromptUserForDelete(container, "organization", moduleOwner.Owner()); err != nil { diff --git a/private/buf/cmd/buf/command/registry/organization/organizationinfo/organizationinfo.go b/private/buf/cmd/buf/command/registry/organization/organizationinfo/organizationinfo.go index 29eaaca8ff..22cef0eb9a 100644 --- a/private/buf/cmd/buf/command/registry/organization/organizationinfo/organizationinfo.go +++ b/private/buf/cmd/buf/command/registry/organization/organizationinfo/organizationinfo.go @@ -74,11 +74,11 @@ func run( ) error { moduleOwner, err := bufcli.ParseModuleOwner(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } format, err := bufprint.ParseFormat(flags.Format) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) diff --git a/private/buf/cmd/buf/command/registry/organization/organizationupdate/organizationupdate.go b/private/buf/cmd/buf/command/registry/organization/organizationupdate/organizationupdate.go index b8b683976b..765ab41230 100644 --- a/private/buf/cmd/buf/command/registry/organization/organizationupdate/organizationupdate.go +++ b/private/buf/cmd/buf/command/registry/organization/organizationupdate/organizationupdate.go @@ -83,7 +83,7 @@ func run( ) error { moduleOwner, err := bufcli.ParseModuleOwner(container.Arg(0)) if err != nil { - return appcmd.NewInvalidArgumentError(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } clientConfig, err := bufcli.NewConnectClientConfig(container) if err != nil { diff --git a/private/buf/cmd/buf/command/registry/registrylogin/registrylogin.go b/private/buf/cmd/buf/command/registry/registrylogin/registrylogin.go index 9fdc3f9a82..288162da64 100644 --- a/private/buf/cmd/buf/command/registry/registrylogin/registrylogin.go +++ b/private/buf/cmd/buf/command/registry/registrylogin/registrylogin.go @@ -178,7 +178,7 @@ func inner( var err error token, err = doBrowserLogin(ctx, container, remote) if err != nil { - if !errors.Is(err, oauth2.ErrUnsupported) { + if !errors.Is(err, errors.ErrUnsupported) { return fmt.Errorf("unable to complete authorize device grant: %w", err) } token, err = doPromptLogin(ctx, container, remote) diff --git a/private/buf/cmd/buf/command/registry/sdk/version/version.go b/private/buf/cmd/buf/command/registry/sdk/version/version.go index 94cd5b32ce..cb96d3d61f 100644 --- a/private/buf/cmd/buf/command/registry/sdk/version/version.go +++ b/private/buf/cmd/buf/command/registry/sdk/version/version.go @@ -91,11 +91,11 @@ func run( ) error { moduleRef, err := bufmodule.ParseModuleRef(flags.Module) if err != nil { - return appcmd.NewInvalidArgumentErrorf(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } pluginIdentity, pluginVersion, err := bufremotepluginref.ParsePluginIdentityOptionalVersion(flags.Plugin) if err != nil { - return appcmd.NewInvalidArgumentErrorf(err.Error()) + return appcmd.WrapInvalidArgumentError(err) } if pluginIdentity.Remote() != moduleRef.ModuleFullName().Registry() { return appcmd.NewInvalidArgumentError("module and plugin must be from the same BSR instance") diff --git a/private/bufpkg/bufcheck/bufbreaking/internal/bufbreakingcheck/bufbreakingcheck.go b/private/bufpkg/bufcheck/bufbreaking/internal/bufbreakingcheck/bufbreakingcheck.go index fd82bd1b9c..f36b3acb65 100644 --- a/private/bufpkg/bufcheck/bufbreaking/internal/bufbreakingcheck/bufbreakingcheck.go +++ b/private/bufpkg/bufcheck/bufbreaking/internal/bufbreakingcheck/bufbreakingcheck.go @@ -332,16 +332,22 @@ func isDeletedFieldAllowedWithRules(previousField bufprotosource.Field, message } // CheckFieldSameCardinality is a check function. -var CheckFieldSameCardinality = newFieldDescriptorPairCheckFunc(checkFieldSameCardinality) +var CheckFieldSameCardinality = newFieldPairCheckFunc(checkFieldSameCardinality) func checkFieldSameCardinality( add addFunc, _ *corpus, - _ bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, + previousField bufprotosource.Field, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } if previousDescriptor.ContainingMessage().IsMapEntry() && descriptor.ContainingMessage().IsMapEntry() { // Map entries are generated so nothing to do here. They // usually would be safe to check anyway, but it's possible @@ -366,16 +372,22 @@ func checkFieldSameCardinality( } // CheckFieldSameCppStringType is a check function. -var CheckFieldSameCppStringType = newFieldDescriptorPairCheckFunc(checkFieldSameCppStringType) +var CheckFieldSameCppStringType = newFieldPairCheckFunc(checkFieldSameCppStringType) func checkFieldSameCppStringType( add addFunc, corpus *corpus, previousField bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } if previousDescriptor.ContainingMessage().IsMapEntry() && descriptor.ContainingMessage().IsMapEntry() { // Map entries, even with string or bytes keys or values, // don't allow configuring the string type. @@ -422,16 +434,22 @@ func checkFieldSameCppStringType( } // CheckFieldSameJavaUTF8Validation is a check function. -var CheckFieldSameJavaUTF8Validation = newFieldDescriptorPairCheckFunc(checkFieldSameJavaUTF8Validation) +var CheckFieldSameJavaUTF8Validation = newFieldPairCheckFunc(checkFieldSameJavaUTF8Validation) func checkFieldSameJavaUTF8Validation( add addFunc, corpus *corpus, previousField bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } if previousDescriptor.Kind() != protoreflect.StringKind || descriptor.Kind() != protoreflect.StringKind { // this check only applies to string fields return nil @@ -459,16 +477,22 @@ func checkFieldSameJavaUTF8Validation( } // CheckFieldSameDefault is a check function. -var CheckFieldSameDefault = newFieldDescriptorPairCheckFunc(checkFieldSameDefault) +var CheckFieldSameDefault = newFieldPairCheckFunc(checkFieldSameDefault) func checkFieldSameDefault( add addFunc, corpus *corpus, previousField bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } if !canHaveDefault(previousDescriptor) || !canHaveDefault(descriptor) { return nil } @@ -610,16 +634,22 @@ func checkFieldSameOneof(add addFunc, corpus *corpus, previousField bufprotosour } // CheckFieldSameType is a check function. -var CheckFieldSameType = newFieldDescriptorPairCheckFunc(checkFieldSameType) +var CheckFieldSameType = newFieldPairCheckFunc(checkFieldSameType) func checkFieldSameType( add addFunc, _ *corpus, previousField bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } // We use descriptor.Kind(), instead of field.Type(), because it also includes // a check of resolved features in Editions files so it can distinguish between // normal (length-prefixed) and delimited (aka "group" encoded) messages, which @@ -641,16 +671,22 @@ func checkFieldSameType( } // CheckFieldSameUTF8Validation is a check function. -var CheckFieldSameUTF8Validation = newFieldDescriptorPairCheckFunc(checkFieldSameUTF8Validation) +var CheckFieldSameUTF8Validation = newFieldPairCheckFunc(checkFieldSameUTF8Validation) func checkFieldSameUTF8Validation( add addFunc, _ *corpus, - _ bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, + previousField bufprotosource.Field, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } if previousDescriptor.Kind() != protoreflect.StringKind || descriptor.Kind() != protoreflect.StringKind { return nil } @@ -683,16 +719,22 @@ func checkFieldSameUTF8Validation( } // CheckFieldWireCompatibleCardinality is a check function. -var CheckFieldWireCompatibleCardinality = newFieldDescriptorPairCheckFunc(checkFieldWireCompatibleCardinality) +var CheckFieldWireCompatibleCardinality = newFieldPairCheckFunc(checkFieldWireCompatibleCardinality) func checkFieldWireCompatibleCardinality( add addFunc, _ *corpus, - _ bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, + previousField bufprotosource.Field, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } if previousDescriptor.ContainingMessage().IsMapEntry() && descriptor.ContainingMessage().IsMapEntry() { // Map entries are generated so nothing to do here. They // usually would be safe to check anyway, but it's possible @@ -717,16 +759,22 @@ func checkFieldWireCompatibleCardinality( } // CheckFieldWireCompatibleType is a check function. -var CheckFieldWireCompatibleType = newFieldDescriptorPairCheckFunc(checkFieldWireCompatibleType) +var CheckFieldWireCompatibleType = newFieldPairCheckFunc(checkFieldWireCompatibleType) func checkFieldWireCompatibleType( add addFunc, corpus *corpus, previousField bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } // We use descriptor.Kind(), instead of field.Type(), because it also includes // a check of resolved features in Editions files so it can distinguish between // normal (length-prefixed) and delimited (aka "group" encoded) messages, which @@ -772,16 +820,22 @@ func checkFieldWireCompatibleType( } // CheckFieldWireJSONCompatibleCardinality is a check function. -var CheckFieldWireJSONCompatibleCardinality = newFieldDescriptorPairCheckFunc(checkFieldWireJSONCompatibleCardinality) +var CheckFieldWireJSONCompatibleCardinality = newFieldPairCheckFunc(checkFieldWireJSONCompatibleCardinality) func checkFieldWireJSONCompatibleCardinality( add addFunc, _ *corpus, - _ bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, + previousField bufprotosource.Field, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } if previousDescriptor.ContainingMessage().IsMapEntry() && descriptor.ContainingMessage().IsMapEntry() { // Map entries are generated so nothing to do here. They // usually would be safe to check anyway, but it's possible @@ -806,16 +860,22 @@ func checkFieldWireJSONCompatibleCardinality( } // CheckFieldWireJSONCompatibleType is a check function. -var CheckFieldWireJSONCompatibleType = newFieldDescriptorPairCheckFunc(checkFieldWireJSONCompatibleType) +var CheckFieldWireJSONCompatibleType = newFieldPairCheckFunc(checkFieldWireJSONCompatibleType) func checkFieldWireJSONCompatibleType( add addFunc, corpus *corpus, previousField bufprotosource.Field, - previousDescriptor protoreflect.FieldDescriptor, field bufprotosource.Field, - descriptor protoreflect.FieldDescriptor, ) error { + previousDescriptor, err := previousField.AsDescriptor() + if err != nil { + return err + } + descriptor, err := field.AsDescriptor() + if err != nil { + return err + } // We use descriptor.Kind(), instead of field.Type(), because it also includes // a check of resolved features in Editions files so it can distinguish between // normal (length-prefixed) and delimited (aka "group" encoded) messages, which diff --git a/private/bufpkg/bufcheck/bufbreaking/internal/bufbreakingcheck/util.go b/private/bufpkg/bufcheck/bufbreaking/internal/bufbreakingcheck/util.go index 14441e643f..3bbea8cdde 100644 --- a/private/bufpkg/bufcheck/bufbreaking/internal/bufbreakingcheck/util.go +++ b/private/bufpkg/bufcheck/bufbreaking/internal/bufbreakingcheck/util.go @@ -302,24 +302,6 @@ func newFieldPairCheckFunc( ) } -func newFieldDescriptorPairCheckFunc( - f func(addFunc, *corpus, bufprotosource.Field, protoreflect.FieldDescriptor, bufprotosource.Field, protoreflect.FieldDescriptor) error, -) func(string, internal.IgnoreFunc, []bufprotosource.File, []bufprotosource.File) ([]bufanalysis.FileAnnotation, error) { - return newFieldPairCheckFunc( - func(add addFunc, corpus *corpus, previousField bufprotosource.Field, field bufprotosource.Field) error { - previousDescriptor, err := previousField.AsDescriptor() - if err != nil { - return err - } - descriptor, err := field.AsDescriptor() - if err != nil { - return err - } - return f(add, corpus, previousField, previousDescriptor, field, descriptor) - }, - ) -} - func newServicePairCheckFunc( f func(addFunc, *corpus, bufprotosource.Service, bufprotosource.Service) error, ) func(string, internal.IgnoreFunc, []bufprotosource.File, []bufprotosource.File) ([]bufanalysis.FileAnnotation, error) { diff --git a/private/bufpkg/bufcheck/bufcheck.go b/private/bufpkg/bufcheck/bufcheck.go index 8e442a18d1..1f166580a9 100644 --- a/private/bufpkg/bufcheck/bufcheck.go +++ b/private/bufpkg/bufcheck/bufcheck.go @@ -29,16 +29,8 @@ import ( "go.uber.org/multierr" ) -// AllRuleFormatStrings is all rule format strings. -var AllRuleFormatStrings = []string{ - "text", - "json", -} - // Rule is a rule. type Rule interface { - json.Marshaler - // ID returns the ID of the Rule. // // UPPER_SNAKE_CASE. @@ -71,22 +63,15 @@ type Rule interface { } // PrintRules prints the rules to the writer. -// -// The empty string defaults to text. -func PrintRules(writer io.Writer, rules []Rule, formatString string, includeDeprecated bool) (retErr error) { +func PrintRules(writer io.Writer, rules []Rule, options ...PrintRulesOption) (retErr error) { + printRulesOptions := newPrintRulesOptions() + for _, option := range options { + option(printRulesOptions) + } if len(rules) == 0 { return nil } - var asJSON bool - switch s := strings.ToLower(strings.TrimSpace(formatString)); s { - case "", "text": - asJSON = false - case "json": - asJSON = true - default: - return fmt.Errorf("unknown format: %q", s) - } - if !asJSON { + if !printRulesOptions.asJSON { tabWriter := tabwriter.NewWriter(writer, 0, 0, 2, ' ', 0) defer func() { retErr = multierr.Append(retErr, tabWriter.Flush()) @@ -97,19 +82,38 @@ func PrintRules(writer io.Writer, rules []Rule, formatString string, includeDepr } } for _, rule := range rules { - if !includeDeprecated && rule.Deprecated() { + if !printRulesOptions.includeDeprecated && rule.Deprecated() { continue } - if err := printRule(writer, rule, asJSON); err != nil { + if err := printRule(writer, rule, printRulesOptions.asJSON); err != nil { return err } } return nil } +// PrintRulesOption is an option for PrintRules. +type PrintRulesOption func(*printRulesOptions) + +// PrintRulesWithJSON returns a new PrintRulesOption that says to print the rules as JSON. +// +// The default is to print as text. +func PrintRulesWithJSON() PrintRulesOption { + return func(printRulesOptions *printRulesOptions) { + printRulesOptions.asJSON = true + } +} + +// PrintRulesWithDeprecated returns a new PrintRulesOption that resullts in deprecated rules being printed. +func PrintRulesWithDeprecated() PrintRulesOption { + return func(printRulesOptions *printRulesOptions) { + printRulesOptions.includeDeprecated = true + } +} + func printRule(writer io.Writer, rule Rule, asJSON bool) error { if asJSON { - data, err := json.Marshal(rule) + data, err := json.Marshal(newExternalRule(rule)) if err != nil { return err } @@ -123,3 +127,30 @@ func printRule(writer io.Writer, rule Rule, asJSON bool) error { } return nil } + +type externalRule struct { + ID string `json:"id" yaml:"id"` + Categories []string `json:"categories" yaml:"categories"` + Purpose string `json:"purpose" yaml:"purpose"` + Deprecated bool `json:"deprecated" yaml:"deprecated"` + Replacements []string `json:"replacements" yaml:"replacements"` +} + +func newExternalRule(rule Rule) *externalRule { + return &externalRule{ + ID: rule.ID(), + Categories: rule.Categories(), + Purpose: rule.Purpose(), + Deprecated: rule.Deprecated(), + Replacements: rule.ReplacementIDs(), + } +} + +type printRulesOptions struct { + asJSON bool + includeDeprecated bool +} + +func newPrintRulesOptions() *printRulesOptions { + return &printRulesOptions{} +} diff --git a/private/bufpkg/bufcheck/buflint/buflint_test.go b/private/bufpkg/bufcheck/buflint/buflint_test.go index a632ae4ed0..fdc24de1cb 100644 --- a/private/bufpkg/bufcheck/buflint/buflint_test.go +++ b/private/bufpkg/bufcheck/buflint/buflint_test.go @@ -929,6 +929,15 @@ func TestRunSyntaxSpecified(t *testing.T) { ) } +func TestRunStablePackageNoImportUnstable(t *testing.T) { + t.Parallel() + testLint( + t, + "lint_stable_package_import", + bufanalysistesting.NewFileAnnotation(t, "api/v1/foo.proto", 5, 1, 5, 32, "STABLE_PACKAGE_NO_IMPORT_UNSTABLE"), + ) +} + func TestRunIgnores1(t *testing.T) { t.Parallel() testLint( diff --git a/private/bufpkg/bufcheck/buflint/internal/buflintbuild/buflintbuild.go b/private/bufpkg/bufcheck/buflint/internal/buflintbuild/buflintbuild.go index ef176d5362..d877b5ea34 100644 --- a/private/bufpkg/bufcheck/buflint/internal/buflintbuild/buflintbuild.go +++ b/private/bufpkg/bufcheck/buflint/internal/buflintbuild/buflintbuild.go @@ -338,6 +338,12 @@ var ( }), nil }, ) + // StablePackageNoImportUnstableRuleBuilder is a rule builder. + StablePackageNoImportUnstableRuleBuilder = internal.NewNopRuleBuilder( + "STABLE_PACKAGE_NO_IMPORT_UNSTABLE", + "all files that have stable versioned packages do not import packages with unstable version packages", + newAdapter(buflintcheck.CheckStablePackageNoImportUnstable), + ) // SyntaxSpecifiedRuleBuilder is a rule builder. SyntaxSpecifiedRuleBuilder = internal.NewNopRuleBuilder( "SYNTAX_SPECIFIED", diff --git a/private/bufpkg/bufcheck/buflint/internal/buflintcheck/buflintcheck.go b/private/bufpkg/bufcheck/buflint/internal/buflintcheck/buflintcheck.go index 0c931f801d..399ae90aa2 100644 --- a/private/bufpkg/bufcheck/buflint/internal/buflintcheck/buflintcheck.go +++ b/private/bufpkg/bufcheck/buflint/internal/buflintcheck/buflintcheck.go @@ -1029,6 +1029,40 @@ func checkServiceSuffix(add addFunc, service bufprotosource.Service, suffix stri return nil } +// CheckStablePackageNoImportUnstable is a check function. +var CheckStablePackageNoImportUnstable = newFilesCheckFunc(checkStablePackageNoImportUnstable) + +func checkStablePackageNoImportUnstable(add addFunc, files []bufprotosource.File) error { + filePathToFile, err := bufprotosource.FilePathToFile(files...) + if err != nil { + return err + } + for _, file := range files { + packageVersion, ok := protoversion.NewPackageVersionForPackage(file.Package()) + if !ok { + // No package, or no version on package - unstable to determine if stable. + continue + } + if packageVersion.StabilityLevel() != protoversion.StabilityLevelStable { + // If package is not stable, no failure. + continue + } + // Package is stable. Check imports. + for _, fileImport := range file.FileImports() { + if importedFile, ok := filePathToFile[fileImport.Import()]; ok { + importedFilePackageVersion, ok := protoversion.NewPackageVersionForPackage(importedFile.Package()) + if !ok { + continue + } + if importedFilePackageVersion.StabilityLevel() != protoversion.StabilityLevelStable { + add(file, fileImport.Location(), nil, `This file is in stable package %q, so it should not depend on %q from unstable package %q.`, file.Package(), fileImport.Import(), importedFile.Package()) + } + } + } + } + return nil +} + // CheckSyntaxSpecified is a check function. var CheckSyntaxSpecified = newFileCheckFunc(checkSyntaxSpecified) diff --git a/private/bufpkg/bufcheck/buflint/internal/buflintv2/buflintv2.go b/private/bufpkg/bufcheck/buflint/internal/buflintv2/buflintv2.go index c07e65c4fc..19a46d7b6d 100644 --- a/private/bufpkg/bufcheck/buflint/internal/buflintv2/buflintv2.go +++ b/private/bufpkg/bufcheck/buflint/internal/buflintv2/buflintv2.go @@ -19,6 +19,7 @@ // The only changes from v1 to v2 are: // 1. New rule PACKAGE_NO_IMPORT_CYCLE was added to MINIMAL, BASIC, DEFAULT. // 2. New rule FIELD_NO_REQUIRED was added to BASIC and DEFAULT. +// 3. New rule STABLE_PACKAGE_NO_IMPORT_UNSTABLE added with no category. package buflintv2 import ( diff --git a/private/bufpkg/bufcheck/buflint/internal/buflintv2/vars.go b/private/bufpkg/bufcheck/buflint/internal/buflintv2/vars.go index ea1808df98..4fd4310ed5 100644 --- a/private/bufpkg/bufcheck/buflint/internal/buflintv2/vars.go +++ b/private/bufpkg/bufcheck/buflint/internal/buflintv2/vars.go @@ -66,6 +66,7 @@ var ( buflintbuild.RPCResponseStandardNameRuleBuilder, buflintbuild.ServicePascalCaseRuleBuilder, buflintbuild.ServiceSuffixRuleBuilder, + buflintbuild.StablePackageNoImportUnstableRuleBuilder, buflintbuild.SyntaxSpecifiedRuleBuilder, } @@ -238,6 +239,7 @@ var ( "SERVICE_SUFFIX": { "DEFAULT", }, + "STABLE_PACKAGE_NO_IMPORT_UNSTABLE": {}, "SYNTAX_SPECIFIED": { "BASIC", "DEFAULT", diff --git a/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/baz/baz.proto b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/baz/baz.proto new file mode 100644 index 0000000000..ad7b2da1f8 --- /dev/null +++ b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/baz/baz.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +package api.baz; + +message Baz {} diff --git a/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/v1/foo.proto b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/v1/foo.proto new file mode 100644 index 0000000000..97847c3781 --- /dev/null +++ b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/v1/foo.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package api.v1; + +import "api/v1alpha/bar.proto"; +import "api/baz/baz.proto"; +import "api/v2/foo.proto"; + +message Foo { + api.v1alpha.Bar bar = 1; + api.baz.Baz baz = 2; + api.v2.Foo foo = 3; +} diff --git a/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/v1alpha/bar.proto b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/v1alpha/bar.proto new file mode 100644 index 0000000000..9a6b806ddf --- /dev/null +++ b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/v1alpha/bar.proto @@ -0,0 +1,5 @@ +syntax = "proto3"; + +package api.v1alpha; + +message Bar {} diff --git a/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/v2/foo.proto b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/v2/foo.proto new file mode 100644 index 0000000000..4ba7e5d0fb --- /dev/null +++ b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/api/v2/foo.proto @@ -0,0 +1,6 @@ +syntax = "proto3"; + +package api.v2; + +message Foo {} + diff --git a/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/buf.yaml b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/buf.yaml new file mode 100644 index 0000000000..4f8b4ff5a7 --- /dev/null +++ b/private/bufpkg/bufcheck/buflint/testdata/lint_stable_package_import/buf.yaml @@ -0,0 +1,4 @@ +version: v2 +lint: + use: + - STABLE_PACKAGE_NO_IMPORT_UNSTABLE diff --git a/private/bufpkg/bufcheck/internal/rule.go b/private/bufpkg/bufcheck/internal/rule.go index 65026a6e73..e1cf99890f 100644 --- a/private/bufpkg/bufcheck/internal/rule.go +++ b/private/bufpkg/bufcheck/internal/rule.go @@ -15,7 +15,6 @@ package internal import ( - "encoding/json" "sort" "github.com/bufbuild/buf/private/bufpkg/bufanalysis" @@ -101,19 +100,6 @@ func (c *Rule) ReplacementIDs() []string { return c.replacementIDs } -// MarshalJSON implements Rule. -func (c *Rule) MarshalJSON() ([]byte, error) { - return json.Marshal(ruleJSON{ID: c.id, Categories: c.categories, Purpose: c.purpose}) -} - func (c *Rule) check(ignoreFunc IgnoreFunc, previousFiles []bufprotosource.File, files []bufprotosource.File) (_ []bufanalysis.FileAnnotation, retErr error) { return c.checkFunc(c.ID(), ignoreFunc, previousFiles, files) } - -type ruleJSON struct { - ID string `json:"id" yaml:"id"` - Categories []string `json:"categories" yaml:"categories"` - Purpose string `json:"purpose" yaml:"purpose"` - Deprecated bool `json:"deprecated" yaml:"deprecated"` - Replacements []string `json:"replacements" yaml:"replacements"` -} diff --git a/private/bufpkg/bufconfig/generate_config.go b/private/bufpkg/bufconfig/generate_config.go index dad48e8717..761c9a4a4c 100644 --- a/private/bufpkg/bufconfig/generate_config.go +++ b/private/bufpkg/bufconfig/generate_config.go @@ -42,85 +42,85 @@ type GenerateConfig interface { // NewGenerateConfig returns a validated GenerateConfig. func NewGenerateConfig( cleanPluginOuts bool, - pluginConfigs []GeneratePluginConfig, - managedConfig GenerateManagedConfig, - typeConfig GenerateTypeConfig, + generatePluginConfigs []GeneratePluginConfig, + generateManagedConfig GenerateManagedConfig, + generateTypeConfig GenerateTypeConfig, ) (GenerateConfig, error) { - if len(pluginConfigs) == 0 { + if len(generatePluginConfigs) == 0 { return nil, newNoPluginsError() } return &generateConfig{ - cleanPluginOuts: cleanPluginOuts, - pluginConfigs: pluginConfigs, - managedConfig: managedConfig, - typeConfig: typeConfig, + cleanPluginOuts: cleanPluginOuts, + generatePluginConfigs: generatePluginConfigs, + generateManagedConfig: generateManagedConfig, + generateTypeConfig: generateTypeConfig, }, nil } // *** PRIVATE *** type generateConfig struct { - cleanPluginOuts bool - pluginConfigs []GeneratePluginConfig - managedConfig GenerateManagedConfig - typeConfig GenerateTypeConfig + cleanPluginOuts bool + generatePluginConfigs []GeneratePluginConfig + generateManagedConfig GenerateManagedConfig + generateTypeConfig GenerateTypeConfig } func newGenerateConfigFromExternalFileV1Beta1( externalFile externalBufGenYAMLFileV1Beta1, ) (GenerateConfig, error) { - managedConfig, err := newManagedConfigFromExternalV1Beta1(externalFile.Managed, externalFile.Options) + generateManagedConfig, err := newGenerateManagedConfigFromExternalV1Beta1(externalFile.Managed, externalFile.Options) if err != nil { return nil, err } if len(externalFile.Plugins) == 0 { return nil, newNoPluginsError() } - pluginConfigs, err := slicesext.MapError( + generatePluginConfigs, err := slicesext.MapError( externalFile.Plugins, - newPluginConfigFromExternalV1Beta1, + newGeneratePluginConfigFromExternalV1Beta1, ) if err != nil { return nil, err } return &generateConfig{ - pluginConfigs: pluginConfigs, - managedConfig: managedConfig, + generatePluginConfigs: generatePluginConfigs, + generateManagedConfig: generateManagedConfig, }, nil } func newGenerateConfigFromExternalFileV1( externalFile externalBufGenYAMLFileV1, ) (GenerateConfig, error) { - managedConfig, err := newManagedConfigFromExternalV1(externalFile.Managed) + generateManagedConfig, err := newGenerateManagedConfigFromExternalV1(externalFile.Managed) if err != nil { return nil, err } if len(externalFile.Plugins) == 0 { return nil, newNoPluginsError() } - pluginConfigs, err := slicesext.MapError( + generatePluginConfigs, err := slicesext.MapError( externalFile.Plugins, - newPluginConfigFromExternalV1, + newGeneratePluginConfigFromExternalV1, ) if err != nil { return nil, err } return &generateConfig{ - pluginConfigs: pluginConfigs, - managedConfig: managedConfig, - typeConfig: newGenerateTypeConfig(externalFile.Types.Include), + generatePluginConfigs: generatePluginConfigs, + generateManagedConfig: generateManagedConfig, + generateTypeConfig: newGenerateTypeConfig(externalFile.Types.Include), }, nil } func newGenerateConfigFromExternalFileV2( externalFile externalBufGenYAMLFileV2, ) (GenerateConfig, error) { - managedConfig, err := newManagedConfigFromExternalV2(externalFile.Managed) + generateManagedConfig, err := newGenerateManagedConfigFromExternalV2(externalFile.Managed) if err != nil { return nil, err } - pluginConfigs, err := slicesext.MapError( + generatePluginConfigs, err := slicesext.MapError( externalFile.Plugins, newPluginConfigFromExternalV2, ) @@ -128,9 +128,9 @@ func newGenerateConfigFromExternalFileV2( return nil, err } return &generateConfig{ - cleanPluginOuts: externalFile.Clean, - managedConfig: managedConfig, - pluginConfigs: pluginConfigs, + cleanPluginOuts: externalFile.Clean, + generateManagedConfig: generateManagedConfig, + generatePluginConfigs: generatePluginConfigs, }, nil } @@ -139,15 +139,15 @@ func (g *generateConfig) CleanPluginOuts() bool { } func (g *generateConfig) GeneratePluginConfigs() []GeneratePluginConfig { - return g.pluginConfigs + return g.generatePluginConfigs } func (g *generateConfig) GenerateManagedConfig() GenerateManagedConfig { - return g.managedConfig + return g.generateManagedConfig } func (g *generateConfig) GenerateTypeConfig() GenerateTypeConfig { - return g.typeConfig + return g.generateTypeConfig } func (*generateConfig) isGenerateConfig() {} diff --git a/private/bufpkg/bufconfig/generate_config_test.go b/private/bufpkg/bufconfig/generate_config_test.go index 299d62373c..53c9f0a811 100644 --- a/private/bufpkg/bufconfig/generate_config_test.go +++ b/private/bufpkg/bufconfig/generate_config_test.go @@ -44,12 +44,12 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: "java", - out: "java/out", + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: "java", + out: "java/out", // one string because it's one string in the config opts: []string{"a=b,c"}, strategy: toPointer(GenerateStrategyAll), @@ -71,14 +71,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: "java", - out: "java/out", - opts: []string{"a"}, - strategy: toPointer(GenerateStrategyAll), + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: "java", + out: "java/out", + opts: []string{"a"}, + strategy: toPointer(GenerateStrategyAll), }, }, }, @@ -98,15 +98,15 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocal, - name: "go", - out: "go/out", - path: []string{"go", "run", "goplugin"}, - opts: []string{"a=b", "c"}, - strategy: toPointer(GenerateStrategyDirectory), + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocal, + name: "go", + out: "go/out", + path: []string{"go", "run", "goplugin"}, + opts: []string{"a=b", "c"}, + strategy: toPointer(GenerateStrategyDirectory), }, }, }, @@ -126,15 +126,15 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocal, - name: "go", - out: "go/out", - path: []string{"go", "run", "goplugin"}, - opts: []string{"a=b", "c"}, - strategy: toPointer(GenerateStrategyDirectory), + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocal, + name: "go", + out: "go/out", + path: []string{"go", "run", "goplugin"}, + opts: []string{"a=b", "c"}, + strategy: toPointer(GenerateStrategyDirectory), }, }, }, @@ -152,13 +152,13 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocal, - name: "go2", - out: "go2/out", - path: []string{"protoc-gen-go"}, + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocal, + name: "go2", + out: "go2/out", + path: []string{"protoc-gen-go"}, }, }, }, @@ -176,13 +176,13 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocal, - name: "go2", - out: "go2/out", - path: []string{"protoc-gen-go"}, + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocal, + name: "go2", + out: "go2/out", + path: []string{"protoc-gen-go"}, }, }, }, @@ -200,13 +200,13 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeProtocBuiltin, - name: "cpp", - out: "cpp/out", - protocPath: []string{"path/to/protoc"}, + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeProtocBuiltin, + name: "cpp", + out: "cpp/out", + protocPath: []string{"path/to/protoc"}, }, }, }, @@ -224,13 +224,13 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeProtocBuiltin, - name: "cpp", - out: "cpp/out", - protocPath: []string{"path/to/protoc", "--experimental_editions"}, + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeProtocBuiltin, + name: "cpp", + out: "cpp/out", + protocPath: []string{"path/to/protoc", "--experimental_editions"}, }, }, }, @@ -248,14 +248,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeRemote, - remoteHost: "buf.build", - revision: 1, - name: "buf.build/protocolbuffers/go:v1.31.0", - out: "go/out", + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeRemote, + remoteHost: "buf.build", + revision: 1, + name: "buf.build/protocolbuffers/go:v1.31.0", + out: "go/out", }, }, }, @@ -273,14 +273,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - managedConfig: &generateManagedConfig{enabled: false}, - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeRemote, - remoteHost: "buf.build", - revision: 1, - name: "buf.build/protocolbuffers/go", - out: "go/out", + generateManagedConfig: &generateManagedConfig{enabled: false}, + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeRemote, + remoteHost: "buf.build", + revision: 1, + name: "buf.build/protocolbuffers/go", + out: "go/out", }, }, }, @@ -300,14 +300,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: "go", - out: "go/out", + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: "go", + out: "go/out", }, }, - managedConfig: &generateManagedConfig{ + generateManagedConfig: &generateManagedConfig{ enabled: true, }, }, @@ -339,14 +339,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: "go", - out: "go/out", + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: "go", + out: "go/out", }, }, - managedConfig: &generateManagedConfig{ + generateManagedConfig: &generateManagedConfig{ enabled: true, disables: []ManagedDisableRule{ &managedDisableRule{ @@ -418,14 +418,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: "go", - out: "go/out", + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: "go", + out: "go/out", }, }, - managedConfig: &generateManagedConfig{ + generateManagedConfig: &generateManagedConfig{ enabled: true, disables: []ManagedDisableRule{ &managedDisableRule{ @@ -474,14 +474,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: "go", - out: "go/out", + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: "go", + out: "go/out", }, }, - managedConfig: &generateManagedConfig{ + generateManagedConfig: &generateManagedConfig{ enabled: true, disables: []ManagedDisableRule{ &managedDisableRule{ @@ -525,14 +525,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: "go", - out: "go/out", + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: "go", + out: "go/out", }, }, - managedConfig: &generateManagedConfig{ + generateManagedConfig: &generateManagedConfig{ enabled: true, disables: []ManagedDisableRule{ &managedDisableRule{ @@ -575,14 +575,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: "go", - out: "go/out", + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: "go", + out: "go/out", }, }, - managedConfig: &generateManagedConfig{ + generateManagedConfig: &generateManagedConfig{ enabled: true, disables: []ManagedDisableRule{ &managedDisableRule{ @@ -631,14 +631,14 @@ func TestParseConfigFromExternalV1(t *testing.T) { }, }, expectedConfig: &generateConfig{ - pluginConfigs: []GeneratePluginConfig{ - &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: "go", - out: "go/out", + generatePluginConfigs: []GeneratePluginConfig{ + &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: "go", + out: "go/out", }, }, - managedConfig: &generateManagedConfig{ + generateManagedConfig: &generateManagedConfig{ enabled: true, overrides: []ManagedOverrideRule{ // ordered by file option names and then by file paths diff --git a/private/bufpkg/bufconfig/generate_managed_config.go b/private/bufpkg/bufconfig/generate_managed_config.go index e2a81dda6a..567d7da5ab 100644 --- a/private/bufpkg/bufconfig/generate_managed_config.go +++ b/private/bufpkg/bufconfig/generate_managed_config.go @@ -88,7 +88,7 @@ func NewManagedDisableRule( fileOption FileOption, fieldOption FieldOption, ) (ManagedDisableRule, error) { - return newDisableRule( + return newManagedDisableRule( path, moduleFullName, fieldName, @@ -132,7 +132,7 @@ func NewManagedOverrideRuleForFileOption( fileOption FileOption, value interface{}, ) (*managedOverrideRule, error) { - return newFileOptionOverrideRule( + return newFileOptionManagedOverrideRule( path, moduleFullName, fileOption, @@ -148,7 +148,7 @@ func NewManagedOverrideRuleForFieldOption( fieldOption FieldOption, value interface{}, ) (ManagedOverrideRule, error) { - return newFieldOptionOverrideRule( + return newFieldOptionManagedOverrideRule( path, moduleFullName, fieldName, @@ -165,7 +165,7 @@ type generateManagedConfig struct { overrides []ManagedOverrideRule } -func newManagedConfigFromExternalV1Beta1( +func newGenerateManagedConfigFromExternalV1Beta1( enabled bool, externalConfig externalGenerateManagedConfigV1Beta1, ) (GenerateManagedConfig, error) { @@ -214,7 +214,7 @@ func newManagedConfigFromExternalV1Beta1( }, nil } -func newManagedConfigFromExternalV1( +func newGenerateManagedConfigFromExternalV1( externalConfig externalGenerateManagedConfigV1, ) (GenerateManagedConfig, error) { var ( @@ -399,7 +399,7 @@ func newManagedConfigFromExternalV1( }, nil } -func newManagedConfigFromExternalV2( +func newGenerateManagedConfigFromExternalV2( externalConfig externalGenerateManagedConfigV2, ) (GenerateManagedConfig, error) { var disables []ManagedDisableRule @@ -422,7 +422,7 @@ func newManagedConfigFromExternalV2( return nil, err } } - disable, err := newDisableRule( + disable, err := newManagedDisableRule( externalDisableConfig.Path, externalDisableConfig.Module, externalDisableConfig.Field, @@ -509,7 +509,7 @@ type managedDisableRule struct { fieldOption FieldOption } -func newDisableRule( +func newManagedDisableRule( path string, moduleFullName string, fieldName string, @@ -575,7 +575,7 @@ type managedOverrideRule struct { value interface{} } -func newFileOptionOverrideRule( +func newFileOptionManagedOverrideRule( path string, moduleFullName string, fileOption FileOption, @@ -611,7 +611,7 @@ func newFileOptionOverrideRule( }, nil } -func newFieldOptionOverrideRule( +func newFieldOptionManagedOverrideRule( path string, moduleFullName string, fieldName string, @@ -694,7 +694,7 @@ func disablesAndOverridesFromExceptAndOverrideV1( return nil, nil, fmt.Errorf("%q is defined multiple times in except", exceptModuleFullName) } seenExceptModuleFullNames[exceptModuleFullName] = struct{}{} - disable, err := newDisableRule( + disable, err := newManagedDisableRule( "", exceptModuleFullName, "", diff --git a/private/bufpkg/bufconfig/generate_plugin_config.go b/private/bufpkg/bufconfig/generate_plugin_config.go index e2509438b1..c0244a5142 100644 --- a/private/bufpkg/bufconfig/generate_plugin_config.go +++ b/private/bufpkg/bufconfig/generate_plugin_config.go @@ -40,21 +40,21 @@ const ( GenerateStrategyAll GenerateStrategy = 2 ) -// PluginConfigType is a plugin configuration type. -type PluginConfigType int +// GeneratePluginConfigType is a generate plugin configuration type. +type GeneratePluginConfigType int const ( - // PluginConfigTypeRemote is the remote plugin config type. - PluginConfigTypeRemote PluginConfigType = iota + 1 - // PluginConfigTypeLocal is the local plugin config type. - PluginConfigTypeLocal - // PluginConfigTypeProtocBuiltin is the protoc built-in plugin config type. - PluginConfigTypeProtocBuiltin - // PluginConfigTypeLocalOrProtocBuiltin is a special plugin config type. This type indicates + // GeneratePluginConfigTypeRemote is the remote plugin config type. + GeneratePluginConfigTypeRemote GeneratePluginConfigType = iota + 1 + // GeneratePluginConfigTypeLocal is the local plugin config type. + GeneratePluginConfigTypeLocal + // GeneratePluginConfigTypeProtocBuiltin is the protoc built-in plugin config type. + GeneratePluginConfigTypeProtocBuiltin + // GeneratePluginConfigTypeLocalOrProtocBuiltin is a special plugin config type. This type indicates // it is to be determined whether the plugin is local or protoc built-in. // We defer further classification to the plugin executor. In v2 the exact // plugin config type is always specified and it will never be just local. - PluginConfigTypeLocalOrProtocBuiltin + GeneratePluginConfigTypeLocalOrProtocBuiltin ) var ( @@ -78,7 +78,7 @@ var ( // GeneratePluginConfig is a configuration for a plugin. type GeneratePluginConfig interface { // Type returns the plugin type. This is never the zero value. - Type() PluginConfigType + Type() GeneratePluginConfigType // Name returns the plugin name. This is never empty. Name() string // Out returns the output directory for generation. This is never empty. @@ -116,8 +116,8 @@ type GeneratePluginConfig interface { isGeneratePluginConfig() } -// NewRemotePluginConfig returns a new GeneratePluginConfig for a remote plugin. -func NewRemotePluginConfig( +// NewRemoteGeneratePluginConfig returns a new GeneratePluginConfig for a remote plugin. +func NewRemoteGeneratePluginConfig( name string, out string, opt []string, @@ -125,7 +125,7 @@ func NewRemotePluginConfig( includeWKT bool, revision int, ) (GeneratePluginConfig, error) { - return newRemotePluginConfig( + return newRemoteGeneratePluginConfig( name, out, opt, @@ -135,8 +135,8 @@ func NewRemotePluginConfig( ) } -// NewLocalOrProtocBuiltinPluginConfig returns a new GeneratePluginConfig for a local or protoc builtin plugin. -func NewLocalOrProtocBuiltinPluginConfig( +// NewLocalOrProtocBuiltinGeneratePluginConfig returns a new GeneratePluginConfig for a local or protoc builtin plugin. +func NewLocalOrProtocBuiltinGeneratePluginConfig( name string, out string, opt []string, @@ -144,7 +144,7 @@ func NewLocalOrProtocBuiltinPluginConfig( includeWKT bool, strategy *GenerateStrategy, ) (GeneratePluginConfig, error) { - return newLocalOrProtocBuiltinPluginConfig( + return newLocalOrProtocBuiltinGeneratePluginConfig( name, out, opt, @@ -154,8 +154,8 @@ func NewLocalOrProtocBuiltinPluginConfig( ) } -// NewLocalPluginConfig returns a new GeneratePluginConfig for a local plugin. -func NewLocalPluginConfig( +// NewLocalGeneratePluginConfig returns a new GeneratePluginConfig for a local plugin. +func NewLocalGeneratePluginConfig( name string, out string, opt []string, @@ -164,7 +164,7 @@ func NewLocalPluginConfig( strategy *GenerateStrategy, path []string, ) (GeneratePluginConfig, error) { - return newLocalPluginConfig( + return newLocalGeneratePluginConfig( name, out, opt, @@ -175,9 +175,9 @@ func NewLocalPluginConfig( ) } -// NewProtocBuiltinPluginConfig returns a new GeneratePluginConfig for a protoc +// NewProtocBuiltinGeneratePluginConfig returns a new GeneratePluginConfig for a protoc // builtin plugin. -func NewProtocBuiltinPluginConfig( +func NewProtocBuiltinGeneratePluginConfig( name string, out string, opt []string, @@ -186,7 +186,7 @@ func NewProtocBuiltinPluginConfig( strategy *GenerateStrategy, protocPath []string, ) (GeneratePluginConfig, error) { - return newProtocBuiltinPluginConfig( + return newProtocBuiltinGeneratePluginConfig( name, out, opt, @@ -197,44 +197,44 @@ func NewProtocBuiltinPluginConfig( ) } -// NewGeneratePluginWithIncludeImportsAndWKT returns a GeneratePluginConfig the +// NewGeneratePluginConfigWithIncludeImportsAndWKT returns a GeneratePluginConfig the // same as the input, with include imports and include wkt overridden. -func NewGeneratePluginWithIncludeImportsAndWKT( +func NewGeneratePluginConfigWithIncludeImportsAndWKT( config GeneratePluginConfig, includeImports bool, includeWKT bool, ) (GeneratePluginConfig, error) { - originalConfig, ok := config.(*pluginConfig) + originalConfig, ok := config.(*generatePluginConfig) if !ok { return nil, syserror.Newf("unknown implementation of GeneratePluginConfig: %T", config) } - pluginConfig := *originalConfig + generatePluginConfig := *originalConfig if includeImports { - pluginConfig.includeImports = true + generatePluginConfig.includeImports = true } if includeWKT { - pluginConfig.includeWKT = true + generatePluginConfig.includeWKT = true } - return &pluginConfig, nil + return &generatePluginConfig, nil } // *** PRIVATE *** -type pluginConfig struct { - pluginConfigType PluginConfigType - name string - out string - opts []string - includeImports bool - includeWKT bool - strategy *GenerateStrategy - path []string - protocPath []string - remoteHost string - revision int +type generatePluginConfig struct { + generatePluginConfigType GeneratePluginConfigType + name string + out string + opts []string + includeImports bool + includeWKT bool + strategy *GenerateStrategy + path []string + protocPath []string + remoteHost string + revision int } -func newPluginConfigFromExternalV1Beta1( +func newGeneratePluginConfigFromExternalV1Beta1( externalConfig externalGeneratePluginConfigV1Beta1, ) (GeneratePluginConfig, error) { if externalConfig.Name == "" { @@ -252,7 +252,7 @@ func newPluginConfigFromExternalV1Beta1( return nil, err } if externalConfig.Path != "" { - return newLocalPluginConfig( + return newLocalGeneratePluginConfig( externalConfig.Name, externalConfig.Out, opt, @@ -262,7 +262,7 @@ func newPluginConfigFromExternalV1Beta1( []string{externalConfig.Path}, ) } - return newLocalOrProtocBuiltinPluginConfig( + return newLocalOrProtocBuiltinGeneratePluginConfig( externalConfig.Name, externalConfig.Out, opt, @@ -272,7 +272,7 @@ func newPluginConfigFromExternalV1Beta1( ) } -func newPluginConfigFromExternalV1( +func newGeneratePluginConfigFromExternalV1( externalConfig externalGeneratePluginConfigV1, ) (GeneratePluginConfig, error) { if externalConfig.Plugin == "" && externalConfig.Name == "" { @@ -321,7 +321,7 @@ func newPluginConfigFromExternalV1( if externalConfig.ProtocPath != nil { return nil, fmt.Errorf("cannot specify protoc_path for remote plugin %s", externalConfig.Plugin) } - return newRemotePluginConfig( + return newRemoteGeneratePluginConfig( externalConfig.Plugin, externalConfig.Out, opt, @@ -333,7 +333,7 @@ func newPluginConfigFromExternalV1( // At this point the plugin must be local, regardless whehter it's specified // by key 'plugin' or 'name'. if len(path) > 0 { - return newLocalPluginConfig( + return newLocalGeneratePluginConfig( pluginIdentifier, externalConfig.Out, opt, @@ -344,7 +344,7 @@ func newPluginConfigFromExternalV1( ) } if externalConfig.ProtocPath != nil { - return newProtocBuiltinPluginConfig( + return newProtocBuiltinGeneratePluginConfig( pluginIdentifier, externalConfig.Out, opt, @@ -356,7 +356,7 @@ func newPluginConfigFromExternalV1( } // It could be either local or protoc built-in. We defer to the plugin executor // to decide whether the plugin is protoc-builtin or local. - return newLocalOrProtocBuiltinPluginConfig( + return newLocalOrProtocBuiltinGeneratePluginConfig( pluginIdentifier, externalConfig.Out, opt, @@ -412,7 +412,7 @@ func newPluginConfigFromExternalV2( if externalConfig.ProtocPath != nil { return nil, fmt.Errorf("cannot specify protoc_path for remote plugin %s", *externalConfig.Remote) } - return newRemotePluginConfig( + return newRemoteGeneratePluginConfig( *externalConfig.Remote, externalConfig.Out, opt, @@ -432,7 +432,7 @@ func newPluginConfigFromExternalV2( if externalConfig.ProtocPath != nil { return nil, fmt.Errorf("cannot specify protoc_path for local plugin %s", localPluginName) } - return newLocalPluginConfig( + return newLocalGeneratePluginConfig( strings.Join(path, " "), externalConfig.Out, opt, @@ -449,7 +449,7 @@ func newPluginConfigFromExternalV2( if externalConfig.Revision != nil { return nil, fmt.Errorf("cannot specify revision for protoc built-in plugin %s", *externalConfig.ProtocBuiltin) } - return newProtocBuiltinPluginConfig( + return newProtocBuiltinGeneratePluginConfig( *externalConfig.ProtocBuiltin, externalConfig.Out, opt, @@ -463,14 +463,14 @@ func newPluginConfigFromExternalV2( } } -func newRemotePluginConfig( +func newRemoteGeneratePluginConfig( name string, out string, opt []string, includeImports bool, includeWKT bool, revision int, -) (*pluginConfig, error) { +) (*generatePluginConfig, error) { if includeWKT && !includeImports { return nil, errors.New("cannot include well-known types without including imports") } @@ -481,41 +481,41 @@ func newRemotePluginConfig( if revision < 0 || revision > math.MaxInt32 { return nil, fmt.Errorf("revision %d is out of accepted range %d-%d", revision, 0, math.MaxInt32) } - return &pluginConfig{ - pluginConfigType: PluginConfigTypeRemote, - name: name, - remoteHost: remoteHost, - revision: revision, - out: out, - opts: opt, - includeImports: includeImports, - includeWKT: includeWKT, + return &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeRemote, + name: name, + remoteHost: remoteHost, + revision: revision, + out: out, + opts: opt, + includeImports: includeImports, + includeWKT: includeWKT, }, nil } -func newLocalOrProtocBuiltinPluginConfig( +func newLocalOrProtocBuiltinGeneratePluginConfig( name string, out string, opt []string, includeImports bool, includeWKT bool, strategy *GenerateStrategy, -) (*pluginConfig, error) { +) (*generatePluginConfig, error) { if includeWKT && !includeImports { return nil, errors.New("cannot include well-known types without including imports") } - return &pluginConfig{ - pluginConfigType: PluginConfigTypeLocalOrProtocBuiltin, - name: name, - strategy: strategy, - out: out, - opts: opt, - includeImports: includeImports, - includeWKT: includeWKT, + return &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocalOrProtocBuiltin, + name: name, + strategy: strategy, + out: out, + opts: opt, + includeImports: includeImports, + includeWKT: includeWKT, }, nil } -func newLocalPluginConfig( +func newLocalGeneratePluginConfig( name string, out string, opt []string, @@ -523,26 +523,26 @@ func newLocalPluginConfig( includeWKT bool, strategy *GenerateStrategy, path []string, -) (*pluginConfig, error) { +) (*generatePluginConfig, error) { if len(path) == 0 { return nil, errors.New("must specify a path to the plugin") } if includeWKT && !includeImports { return nil, errors.New("cannot include well-known types without including imports") } - return &pluginConfig{ - pluginConfigType: PluginConfigTypeLocal, - name: name, - path: path, - strategy: strategy, - out: out, - opts: opt, - includeImports: includeImports, - includeWKT: includeWKT, + return &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeLocal, + name: name, + path: path, + strategy: strategy, + out: out, + opts: opt, + includeImports: includeImports, + includeWKT: includeWKT, }, nil } -func newProtocBuiltinPluginConfig( +func newProtocBuiltinGeneratePluginConfig( name string, out string, opt []string, @@ -550,75 +550,75 @@ func newProtocBuiltinPluginConfig( includeWKT bool, strategy *GenerateStrategy, protocPath []string, -) (*pluginConfig, error) { +) (*generatePluginConfig, error) { if includeWKT && !includeImports { return nil, errors.New("cannot include well-known types without including imports") } - return &pluginConfig{ - pluginConfigType: PluginConfigTypeProtocBuiltin, - name: name, - protocPath: protocPath, - out: out, - opts: opt, - strategy: strategy, - includeImports: includeImports, - includeWKT: includeWKT, + return &generatePluginConfig{ + generatePluginConfigType: GeneratePluginConfigTypeProtocBuiltin, + name: name, + protocPath: protocPath, + out: out, + opts: opt, + strategy: strategy, + includeImports: includeImports, + includeWKT: includeWKT, }, nil } -func (p *pluginConfig) Type() PluginConfigType { - return p.pluginConfigType +func (p *generatePluginConfig) Type() GeneratePluginConfigType { + return p.generatePluginConfigType } -func (p *pluginConfig) Name() string { +func (p *generatePluginConfig) Name() string { return p.name } -func (p *pluginConfig) Out() string { +func (p *generatePluginConfig) Out() string { return p.out } -func (p *pluginConfig) Opt() string { +func (p *generatePluginConfig) Opt() string { return strings.Join(p.opts, ",") } -func (p *pluginConfig) IncludeImports() bool { +func (p *generatePluginConfig) IncludeImports() bool { return p.includeImports } -func (p *pluginConfig) IncludeWKT() bool { +func (p *generatePluginConfig) IncludeWKT() bool { return p.includeWKT } -func (p *pluginConfig) Strategy() GenerateStrategy { +func (p *generatePluginConfig) Strategy() GenerateStrategy { if p.strategy == nil { return GenerateStrategyDirectory } return *p.strategy } -func (p *pluginConfig) Path() []string { +func (p *generatePluginConfig) Path() []string { return p.path } -func (p *pluginConfig) ProtocPath() []string { +func (p *generatePluginConfig) ProtocPath() []string { return p.protocPath } -func (p *pluginConfig) RemoteHost() string { +func (p *generatePluginConfig) RemoteHost() string { return p.remoteHost } -func (p *pluginConfig) Revision() int { +func (p *generatePluginConfig) Revision() int { return p.revision } -func (p *pluginConfig) isGeneratePluginConfig() {} +func (p *generatePluginConfig) isGeneratePluginConfig() {} func newExternalGeneratePluginConfigV2FromPluginConfig( - generatePluginConfig GeneratePluginConfig, + pluginConfig GeneratePluginConfig, ) (externalGeneratePluginConfigV2, error) { - pluginConfig, ok := generatePluginConfig.(*pluginConfig) + generatePluginConfig, ok := pluginConfig.(*generatePluginConfig) if !ok { return externalGeneratePluginConfigV2{}, syserror.Newf("unknown implementation of GeneratePluginConfig: %T", generatePluginConfig) } @@ -627,14 +627,14 @@ func newExternalGeneratePluginConfigV2FromPluginConfig( IncludeImports: generatePluginConfig.IncludeImports(), IncludeWKT: generatePluginConfig.IncludeWKT(), } - opts := pluginConfig.opts + opts := generatePluginConfig.opts switch { case len(opts) == 1: externalPluginConfigV2.Opt = opts[0] case len(opts) > 1: externalPluginConfigV2.Opt = opts } - strategy := pluginConfig.strategy + strategy := generatePluginConfig.strategy switch { case strategy != nil && *strategy == GenerateStrategyDirectory: externalPluginConfigV2.Strategy = toPointer("directory") @@ -642,12 +642,12 @@ func newExternalGeneratePluginConfigV2FromPluginConfig( externalPluginConfigV2.Strategy = toPointer("all") } switch generatePluginConfig.Type() { - case PluginConfigTypeRemote: + case GeneratePluginConfigTypeRemote: externalPluginConfigV2.Remote = toPointer(generatePluginConfig.Name()) if revision := generatePluginConfig.Revision(); revision != 0 { externalPluginConfigV2.Revision = &revision } - case PluginConfigTypeLocal: + case GeneratePluginConfigTypeLocal: path := generatePluginConfig.Path() switch { case len(path) == 1: @@ -655,7 +655,7 @@ func newExternalGeneratePluginConfigV2FromPluginConfig( case len(path) > 1: externalPluginConfigV2.Local = path } - case PluginConfigTypeProtocBuiltin: + case GeneratePluginConfigTypeProtocBuiltin: externalPluginConfigV2.ProtocBuiltin = toPointer(generatePluginConfig.Name()) if protocPath := generatePluginConfig.ProtocPath(); len(protocPath) > 0 { if len(protocPath) == 1 { @@ -664,7 +664,7 @@ func newExternalGeneratePluginConfigV2FromPluginConfig( externalPluginConfigV2.ProtocPath = protocPath } } - case PluginConfigTypeLocalOrProtocBuiltin: + case GeneratePluginConfigTypeLocalOrProtocBuiltin: binaryName := "protoc-gen-" + generatePluginConfig.Name() // First, check if this is a binary. _, err := exec.LookPath(binaryName) diff --git a/private/bufpkg/bufimage/bufimage.go b/private/bufpkg/bufimage/bufimage.go index ec5a3d1d51..ce9298a275 100644 --- a/private/bufpkg/bufimage/bufimage.go +++ b/private/bufpkg/bufimage/bufimage.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "io/fs" + "slices" "sort" "strings" @@ -725,7 +726,7 @@ func appendWellKnownTypeImageFileInfos( return nil, err } wktPaths := slicesext.Map(wktObjectInfos, storage.ObjectInfo.Path) - if !slicesext.Equal(datawkt.AllFilePaths, wktPaths) { + if !slices.Equal(datawkt.AllFilePaths, wktPaths) { return nil, syserror.Newf("wktBucket paths %s are not equal to datawkt.AllFilePaths %s", strings.Join(wktPaths, ","), strings.Join(datawkt.AllFilePaths, ",")) } resultImageFileInfos := slicesext.Copy(imageFileInfos) diff --git a/private/bufpkg/bufmodule/added_module.go b/private/bufpkg/bufmodule/added_module.go index bcb6a21ff7..9d1a40be66 100644 --- a/private/bufpkg/bufmodule/added_module.go +++ b/private/bufpkg/bufmodule/added_module.go @@ -19,10 +19,10 @@ import ( "fmt" "sort" "strings" + "sync" "github.com/bufbuild/buf/private/pkg/slicesext" "github.com/bufbuild/buf/private/pkg/storage" - "github.com/bufbuild/buf/private/pkg/syncext" "github.com/bufbuild/buf/private/pkg/syserror" "github.com/gofrs/uuid/v5" ) @@ -108,7 +108,7 @@ func (a *addedModule) ToModule( return a.localModule, nil } // Else, get the remote Module. - getModuleData := syncext.OnceValues( + getModuleData := sync.OnceValues( func() (ModuleData, error) { moduleDatas, err := moduleDataProvider.GetModuleDatasForModuleKeys( ctx, @@ -134,7 +134,7 @@ func (a *addedModule) ToModule( return moduleData, nil }, ) - getBucket := syncext.OnceValues( + getBucket := sync.OnceValues( func() (storage.ReadBucket, error) { moduleData, err := getModuleData() if err != nil { diff --git a/private/bufpkg/bufmodule/commit.go b/private/bufpkg/bufmodule/commit.go index 1933476447..a5c57a6d00 100644 --- a/private/bufpkg/bufmodule/commit.go +++ b/private/bufpkg/bufmodule/commit.go @@ -15,9 +15,8 @@ package bufmodule import ( + "sync" "time" - - "github.com/bufbuild/buf/private/pkg/syncext" ) // Commit represents a Commit on the BSR. @@ -102,7 +101,7 @@ func newCommit( } return &commit{ moduleKey: moduleKey, - getCreateTime: syncext.OnceValues(getCreateTime), + getCreateTime: sync.OnceValues(getCreateTime), } } diff --git a/private/bufpkg/bufmodule/file_info.go b/private/bufpkg/bufmodule/file_info.go index 220b347e8b..fdb66d34bd 100644 --- a/private/bufpkg/bufmodule/file_info.go +++ b/private/bufpkg/bufmodule/file_info.go @@ -15,9 +15,10 @@ package bufmodule import ( + "sync" + "github.com/bufbuild/buf/private/pkg/slicesext" "github.com/bufbuild/buf/private/pkg/storage" - "github.com/bufbuild/buf/private/pkg/syncext" ) // FileInfo is the file info for a Module file. @@ -88,8 +89,8 @@ func newFileInfo( module: module, fileType: fileType, isTargetFile: isTargetFile, - getProtoFileImports: syncext.OnceValues(getProtoFileImports), - getProtoFilePackage: syncext.OnceValues(getProtoFilePackage), + getProtoFileImports: sync.OnceValues(getProtoFileImports), + getProtoFilePackage: sync.OnceValues(getProtoFilePackage), } } diff --git a/private/bufpkg/bufmodule/module.go b/private/bufpkg/bufmodule/module.go index 18eb3d3940..a30ca5efcc 100644 --- a/private/bufpkg/bufmodule/module.go +++ b/private/bufpkg/bufmodule/module.go @@ -16,11 +16,11 @@ package bufmodule import ( "context" + "sync" "github.com/bufbuild/buf/private/pkg/normalpath" "github.com/bufbuild/buf/private/pkg/slicesext" "github.com/bufbuild/buf/private/pkg/storage" - "github.com/bufbuild/buf/private/pkg/syncext" "github.com/bufbuild/buf/private/pkg/syserror" "github.com/gofrs/uuid/v5" ) @@ -261,7 +261,7 @@ type module struct { // must set ModuleReadBucket after constructor via setModuleReadBucket func newModule( ctx context.Context, - // This function must already be filtered to include only module files and must be syncext.OnceValues wrapped! + // This function must already be filtered to include only module files and must be sync.OnceValues wrapped! syncOnceValuesGetBucketWithStorageMatcherApplied func() (storage.ReadBucket, error), bucketID string, moduleFullName ModuleFullName, @@ -320,9 +320,9 @@ func newModule( commitID: commitID, isTarget: isTarget, isLocal: isLocal, - getV1BufYAMLObjectData: syncext.OnceValues(getV1BufYAMLObjectData), - getV1BufLockObjectData: syncext.OnceValues(getV1BufLockObjectData), - getDeclaredDepModuleKeysB5: syncext.OnceValues(getDeclaredDepModuleKeysB5), + getV1BufYAMLObjectData: sync.OnceValues(getV1BufYAMLObjectData), + getV1BufLockObjectData: sync.OnceValues(getV1BufLockObjectData), + getDeclaredDepModuleKeysB5: sync.OnceValues(getDeclaredDepModuleKeysB5), } moduleReadBucket, err := newModuleReadBucketForModule( ctx, @@ -338,7 +338,7 @@ func newModule( } module.ModuleReadBucket = moduleReadBucket module.digestTypeToGetDigest = newSyncOnceValueDigestTypeToGetDigestFuncForModule(module) - module.getModuleDeps = syncext.OnceValues(newGetModuleDepsFuncForModule(module)) + module.getModuleDeps = sync.OnceValues(newGetModuleDepsFuncForModule(module)) return module, nil } @@ -397,7 +397,7 @@ func (m *module) ModuleSet() ModuleSet { } func (m *module) withIsTarget(isTarget bool) (Module, error) { - // We don't just call newModule directly as we don't want to double syncext.OnceValues stuff. + // We don't just call newModule directly as we don't want to double sync.OnceValues stuff. newModule := &module{ ctx: m.ctx, getBucket: m.getBucket, @@ -416,7 +416,7 @@ func (m *module) withIsTarget(isTarget bool) (Module, error) { } newModule.ModuleReadBucket = moduleReadBucket.withModule(newModule) newModule.digestTypeToGetDigest = newSyncOnceValueDigestTypeToGetDigestFuncForModule(newModule) - newModule.getModuleDeps = syncext.OnceValues(newGetModuleDepsFuncForModule(newModule)) + newModule.getModuleDeps = sync.OnceValues(newGetModuleDepsFuncForModule(newModule)) return newModule, nil } @@ -429,7 +429,7 @@ func (*module) isModule() {} func newSyncOnceValueDigestTypeToGetDigestFuncForModule(module *module) map[DigestType]func() (Digest, error) { m := make(map[DigestType]func() (Digest, error)) for digestType := range digestTypeToString { - m[digestType] = syncext.OnceValues(newGetDigestFuncForModuleAndDigestType(module, digestType)) + m[digestType] = sync.OnceValues(newGetDigestFuncForModuleAndDigestType(module, digestType)) } return m } diff --git a/private/bufpkg/bufmodule/module_data.go b/private/bufpkg/bufmodule/module_data.go index c85a7f45fd..e6be42d571 100644 --- a/private/bufpkg/bufmodule/module_data.go +++ b/private/bufpkg/bufmodule/module_data.go @@ -16,9 +16,9 @@ package bufmodule import ( "context" + "sync" "github.com/bufbuild/buf/private/pkg/storage" - "github.com/bufbuild/buf/private/pkg/syncext" ) // ModuleData presents raw Module data read by ModuleKey. @@ -108,11 +108,11 @@ func newModuleData( moduleData := &moduleData{ moduleKey: moduleKey, getBucket: getSyncOnceValuesGetBucketWithStorageMatcherApplied(ctx, getBucket), - getDeclaredDepModuleKeys: syncext.OnceValues(getDeclaredDepModuleKeys), - getV1BufYAMLObjectData: syncext.OnceValues(getV1BufYAMLObjectData), - getV1BufLockObjectData: syncext.OnceValues(getV1BufLockObjectData), + getDeclaredDepModuleKeys: sync.OnceValues(getDeclaredDepModuleKeys), + getV1BufYAMLObjectData: sync.OnceValues(getV1BufYAMLObjectData), + getV1BufLockObjectData: sync.OnceValues(getV1BufLockObjectData), } - moduleData.checkDigest = syncext.OnceValue( + moduleData.checkDigest = sync.OnceValue( func() error { // We have to use the get.* functions so that we don't invoke checkDigest. bucket, err := moduleData.getBucket() diff --git a/private/bufpkg/bufmodule/module_key.go b/private/bufpkg/bufmodule/module_key.go index 67d72c36db..0fc25149ae 100644 --- a/private/bufpkg/bufmodule/module_key.go +++ b/private/bufpkg/bufmodule/module_key.go @@ -18,9 +18,9 @@ import ( "errors" "fmt" "strings" + "sync" "github.com/bufbuild/buf/private/pkg/slicesext" - "github.com/bufbuild/buf/private/pkg/syncext" "github.com/bufbuild/buf/private/pkg/syserror" "github.com/bufbuild/buf/private/pkg/uuidutil" "github.com/gofrs/uuid/v5" @@ -141,7 +141,7 @@ func newModuleKeyNoValidate( return &moduleKey{ moduleFullName: moduleFullName, commitID: commitID, - getDigest: syncext.OnceValues(getDigest), + getDigest: sync.OnceValues(getDigest), } } diff --git a/private/bufpkg/bufmodule/module_read_bucket.go b/private/bufpkg/bufmodule/module_read_bucket.go index 9ccb196859..4c346b4e32 100644 --- a/private/bufpkg/bufmodule/module_read_bucket.go +++ b/private/bufpkg/bufmodule/module_read_bucket.go @@ -26,6 +26,7 @@ import ( "github.com/bufbuild/buf/private/pkg/normalpath" "github.com/bufbuild/buf/private/pkg/slicesext" "github.com/bufbuild/buf/private/pkg/storage" + "github.com/bufbuild/buf/private/pkg/storage/storagemem" "github.com/bufbuild/buf/private/pkg/syserror" "github.com/bufbuild/protocompile/parser/fastscan" "go.uber.org/multierr" @@ -228,20 +229,39 @@ func GetLicenseFile(ctx context.Context, moduleReadBucket ModuleReadBucket) (Fil // GetDocStorageReadBucket gets a storage.ReadBucket that just contains the documentation file(s). // // This is needed for i.e. using RootToExcludes in NewWorkspaceForBucket. -func GetDocStorageReadBucket(ctx context.Context, bucket storage.ReadBucket) storage.ReadBucket { - return storage.FilterReadBucket( - bucket, - storage.MatchPathEqual(getDocFilePathForStorageReadBucket(ctx, bucket)), +func GetDocStorageReadBucket(ctx context.Context, bucket storage.ReadBucket) (storage.ReadBucket, error) { + // Store the documentation file in a new memory bucket for performance reasons. + docFilePath := getDocFilePathForStorageReadBucket(ctx, bucket) + if docFilePath == "" { + return storage.MultiReadBucket(), nil // nop bucket + } + content, err := storage.ReadPath(ctx, bucket, docFilePath) + if err != nil { + return nil, err + } + return storagemem.NewReadBucket( + map[string][]byte{ + docFilePath: content, + }, ) } // GetLicenseStorageReadBucket gets a storage.ReadBucket that just contains the license file(s). // // This is needed for i.e. using RootToExcludes in NewWorkspaceForBucket. -func GetLicenseStorageReadBucket(bucket storage.ReadBucket) storage.ReadBucket { - return storage.FilterReadBucket( - bucket, - storage.MatchPathEqual(licenseFilePath), +func GetLicenseStorageReadBucket(ctx context.Context, bucket storage.ReadBucket) (storage.ReadBucket, error) { + // Store the license file in a new memory bucket for performance reasons. + content, err := storage.ReadPath(ctx, bucket, licenseFilePath) + if err != nil { + if errors.Is(err, fs.ErrNotExist) { + return storage.MultiReadBucket(), nil // nop bucket + } + return nil, err + } + return storagemem.NewReadBucket( + map[string][]byte{ + licenseFilePath: content, + }, ) } diff --git a/private/bufpkg/bufmodule/paths.go b/private/bufpkg/bufmodule/paths.go index 219e2762d0..07163f0934 100644 --- a/private/bufpkg/bufmodule/paths.go +++ b/private/bufpkg/bufmodule/paths.go @@ -16,10 +16,10 @@ package bufmodule import ( "context" + "sync" "github.com/bufbuild/buf/private/pkg/slicesext" "github.com/bufbuild/buf/private/pkg/storage" - "github.com/bufbuild/buf/private/pkg/syncext" ) const ( @@ -75,7 +75,7 @@ func getStorageMatcher(ctx context.Context, bucket storage.ReadBucket) storage.M ) } -// getSyncOnceValuesGetBucketWithStorageMatcherApplied wraps the getBucket function with syncext.OnceValues +// getSyncOnceValuesGetBucketWithStorageMatcherApplied wraps the getBucket function with sync.OnceValues // and getStorageMatcher applied. // // This is used when constructing moduleReadBuckets in moduleSetBuilder, and when getting a bucket for @@ -84,7 +84,7 @@ func getSyncOnceValuesGetBucketWithStorageMatcherApplied( ctx context.Context, getBucket func() (storage.ReadBucket, error), ) func() (storage.ReadBucket, error) { - return syncext.OnceValues( + return sync.OnceValues( func() (storage.ReadBucket, error) { bucket, err := getBucket() if err != nil { diff --git a/private/bufpkg/bufprotoplugin/generator.go b/private/bufpkg/bufprotoplugin/generator.go index 20b0354ee9..523c826388 100644 --- a/private/bufpkg/bufprotoplugin/generator.go +++ b/private/bufpkg/bufprotoplugin/generator.go @@ -72,9 +72,7 @@ func (g *generator) Generate( ) } } - ctx, cancel := context.WithCancel(ctx) - defer cancel() - if err := thread.Parallelize(ctx, jobs, thread.ParallelizeWithCancel(cancel)); err != nil { + if err := thread.Parallelize(ctx, jobs, thread.ParallelizeWithCancelOnFailure()); err != nil { return nil, err } codeGeneratorResponse, err := protopluginResponseWriter.ToCodeGeneratorResponse() diff --git a/private/bufpkg/bufprotosource/location_store.go b/private/bufpkg/bufprotosource/location_store.go index af40aab6c3..c560a10ffc 100644 --- a/private/bufpkg/bufprotosource/location_store.go +++ b/private/bufpkg/bufprotosource/location_store.go @@ -15,7 +15,8 @@ package bufprotosource import ( - "github.com/bufbuild/buf/private/pkg/syncext" + "sync" + "google.golang.org/protobuf/types/descriptorpb" ) @@ -30,7 +31,7 @@ func newLocationStore(fileDescriptorProto *descriptorpb.FileDescriptorProto) *lo filePath: fileDescriptorProto.GetName(), sourceCodeInfoLocations: fileDescriptorProto.GetSourceCodeInfo().GetLocation(), } - locationStore.getPathToLocation = syncext.OnceValue(locationStore.getPathToLocationUncached) + locationStore.getPathToLocation = sync.OnceValue(locationStore.getPathToLocationUncached) return locationStore } diff --git a/private/bufpkg/bufremoteplugin/bufremoteplugindocker/docker.go b/private/bufpkg/bufremoteplugin/bufremoteplugindocker/docker.go index 9c85876bda..8fd3399268 100644 --- a/private/bufpkg/bufremoteplugin/bufremoteplugindocker/docker.go +++ b/private/bufpkg/bufremoteplugin/bufremoteplugindocker/docker.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "io" + "regexp" "strings" "sync" "time" @@ -29,6 +30,7 @@ import ( "github.com/docker/docker/api/types" imagetypes "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" + imagev1 "github.com/docker/docker/image/v1" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/stringid" "go.uber.org/multierr" @@ -46,6 +48,13 @@ const ( BufUpstreamClientUserAgentPrefix = "buf-cli-" ) +// imageDigestRe is a regular expression for extracting the image digest from the output of a docker +// push command. It is tightly coupled to the string representation because the stream response +// itself is not very well defined. +// +// https://github.com/moby/moby/blob/1c282d1f1b90ff188a1b46f48548ac3151ca2ddf/daemon/containerd/image_push.go#L130 +var imageDigestRe = regexp.MustCompile(`digest:\s*(\S+)`) + // Client is a small abstraction over a Docker API client, providing the basic APIs we need to build plugins. // It ensures that we pass the appropriate parameters to build images (i.e. platform 'linux/amd64'). type Client interface { @@ -128,7 +137,7 @@ func (d *dockerAPIClient) Load(ctx context.Context, image io.Reader) (_ *LoadRes d.logger.Warn("Unsupported image digest", zap.String("imageID", loadedImageID)) continue } - if err := stringid.ValidateID(strings.TrimPrefix(loadedImageID, "sha256:")); err != nil { + if err := imagev1.ValidateID(strings.TrimPrefix(loadedImageID, "sha256:")); err != nil { d.logger.Warn("Invalid image id", zap.String("imageID", loadedImageID)) continue } @@ -182,12 +191,7 @@ func (d *dockerAPIClient) Push(ctx context.Context, image string, auth *Registry if message.Error != nil { return nil, message.Error } - if message.Aux != nil { - var pushResult types.PushResult - if err := json.Unmarshal(*message.Aux, &pushResult); err == nil { - imageDigest = pushResult.Digest - } - } + imageDigest = getImageDigestFromMessage(message) } } if err := pushScanner.Err(); err != nil { @@ -196,9 +200,26 @@ func (d *dockerAPIClient) Push(ctx context.Context, image string, auth *Registry if len(imageDigest) == 0 { return nil, fmt.Errorf("failed to determine image digest after push") } + d.logger.Debug("docker image digest", zap.String("imageDigest", imageDigest)) return &PushResponse{Digest: imageDigest}, nil } +func getImageDigestFromMessage(message jsonmessage.JSONMessage) string { + if message.Aux != nil { + var pushResult types.PushResult + if err := json.Unmarshal(*message.Aux, &pushResult); err == nil { + return pushResult.Digest + } + } + // If the message has no aux field, we fall back to parsing the status field. + if message.Status != "" { + if match := imageDigestRe.FindStringSubmatch(message.Status); len(match) > 1 { + return match[1] + } + } + return "" +} + func (d *dockerAPIClient) Delete(ctx context.Context, image string) (*DeleteResponse, error) { if err := d.negotiateVersion(ctx); err != nil { return nil, err diff --git a/private/bufpkg/bufremoteplugin/bufremoteplugindocker/docker_test.go b/private/bufpkg/bufremoteplugin/bufremoteplugindocker/docker_test.go index 0d1f2b6a78..431993d6f4 100644 --- a/private/bufpkg/bufremoteplugin/bufremoteplugindocker/docker_test.go +++ b/private/bufpkg/bufremoteplugin/bufremoteplugindocker/docker_test.go @@ -103,6 +103,32 @@ func TestMain(m *testing.M) { } } +func TestGetImageDigestFromMessage(t *testing.T) { + t.Parallel() + assertImageDigestFromStatusString(t, + "v1.4.0: digest: sha256:83189bf0fa178c5947af0bcfcf8b9e955c67bf13c4bea0eee145fbfc3e8398d8 size: 855", + "sha256:83189bf0fa178c5947af0bcfcf8b9e955c67bf13c4bea0eee145fbfc3e8398d8", + ) + assertImageDigestFromStatusString(t, + "v1.4.0: digest: sha512:4b230b5e4e3518cf1f16e0a5d3293245cd6f27df350aed72c9eb59fc4b5b5ef764cb0aaea201ea70eab68ca7388533384c4d0e690eaba7f2cd7a0e8939db986f size: 855", "sha512:4b230b5e4e3518cf1f16e0a5d3293245cd6f27df350aed72c9eb59fc4b5b5ef764cb0aaea201ea70eab68ca7388533384c4d0e690eaba7f2cd7a0e8939db986f", + ) + assertImageDigestFromStatusString(t, + "digest: sha256:83189bf0fa178c5947af0bcfcf8b9e955c67bf13c4bea0eee145fbfc3e8398d8", + "sha256:83189bf0fa178c5947af0bcfcf8b9e955c67bf13c4bea0eee145fbfc3e8398d8", + ) + // malformed, missing "digest:" + assertImageDigestFromStatusString(t, + "sha256:83189bf0fa178c5947af0bcfcf8b9e955c67bf13c4bea0eee145fbfc3e8398d8", + "", + ) +} + +func assertImageDigestFromStatusString(t *testing.T, status string, expectedDigest string) { + t.Helper() + digest := getImageDigestFromMessage(jsonmessage.JSONMessage{Status: status}) + assert.Equal(t, expectedDigest, digest) +} + func createClient(t testing.TB, options ...ClientOption) Client { t.Helper() logger, err := zap.NewDevelopment() diff --git a/private/pkg/app/appcmd/appcmd.go b/private/pkg/app/appcmd/appcmd.go index 70cf3fbf07..f57e70ee22 100644 --- a/private/pkg/app/appcmd/appcmd.go +++ b/private/pkg/app/appcmd/appcmd.go @@ -74,7 +74,7 @@ type Command struct { Version string } -// NewInvalidArgumentError creates a new invalidArgumentError, indicating that +// NewInvalidArgumentError creates a new InvalidArgumentError, indicating that // the error was caused by argument validation. This causes us to print the usage // help text for the command that it is returned from. func NewInvalidArgumentError(message string) error { @@ -88,6 +88,13 @@ func NewInvalidArgumentErrorf(format string, args ...any) error { return newInvalidArgumentError(fmt.Errorf(format, args...)) } +// WrapInvalidArgumentError creates a new InvalidArgumentError, indicating that +// the error was caused by argument validation. This causes us to print the usage +// help text for the command that it is returned from. +func WrapInvalidArgumentError(delegate error) error { + return newInvalidArgumentError(delegate) +} + // Main runs the application using the OS container and calling os.Exit on the return value of Run. func Main(ctx context.Context, command *Command) { app.Main(ctx, newRunFunc(command)) diff --git a/private/pkg/app/appcmd/positional_args.go b/private/pkg/app/appcmd/positional_args.go index 66798b76dd..9f80072bf5 100644 --- a/private/pkg/app/appcmd/positional_args.go +++ b/private/pkg/app/appcmd/positional_args.go @@ -44,8 +44,8 @@ func ExactArgs(n int) PositionalArgs { } // RangeArgs matches cobra.RangeArgs. -func RangeArgs(min int, max int) PositionalArgs { - return newPositionalArgs(cobra.RangeArgs(min, max)) +func RangeArgs(minimum int, maximum int) PositionalArgs { + return newPositionalArgs(cobra.RangeArgs(minimum, maximum)) } // PostionalArgs matches cobra.PositionalArgs so that importers of appcmd do diff --git a/private/pkg/bandeps/checker.go b/private/pkg/bandeps/checker.go index eb54c5f7c9..3afa72e4d1 100644 --- a/private/pkg/bandeps/checker.go +++ b/private/pkg/bandeps/checker.go @@ -144,9 +144,7 @@ func (c *checker) populateState(ctx context.Context, state *state, externalConfi }, ) } - ctx, cancel := context.WithCancel(ctx) - defer cancel() - if err := thread.Parallelize(ctx, jobs, thread.ParallelizeWithCancel(cancel)); err != nil { + if err := thread.Parallelize(ctx, jobs, thread.ParallelizeWithCancelOnFailure()); err != nil { return err } @@ -161,5 +159,5 @@ func (c *checker) populateState(ctx context.Context, state *state, externalConfi }, ) } - return thread.Parallelize(ctx, jobs, thread.ParallelizeWithCancel(cancel)) + return thread.Parallelize(ctx, jobs, thread.ParallelizeWithCancelOnFailure()) } diff --git a/private/pkg/dag/dagtest/dagtest.go b/private/pkg/dag/dagtest/dagtest.go index b1abc9b06c..baf212c83d 100644 --- a/private/pkg/dag/dagtest/dagtest.go +++ b/private/pkg/dag/dagtest/dagtest.go @@ -15,6 +15,7 @@ package dagtest import ( + "cmp" "sort" "testing" @@ -23,17 +24,7 @@ import ( "github.com/stretchr/testify/require" ) -// Ordered matches cmp.Ordered until we only support Go versions >= 1.21. -// -// TODO: remove and replace with cmp.Ordered when we only support Go versions >= 1.21. -type Ordered interface { - ~int | ~int8 | ~int16 | ~int32 | ~int64 | - ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | - ~float32 | ~float64 | - ~string -} - -type ExpectedNode[Key Ordered] struct { +type ExpectedNode[Key cmp.Ordered] struct { Key Key Outbound []Key } @@ -42,7 +33,7 @@ type ExpectedNode[Key Ordered] struct { // // The order of the input ExpectedNodes does not matter, and the order of // the outbound Keys does not matter. -func RequireComparableGraphEqual[Key Ordered]( +func RequireComparableGraphEqual[Key cmp.Ordered]( t *testing.T, expected []ExpectedNode[Key], comparableGraph *dag.ComparableGraph[Key], @@ -54,7 +45,7 @@ func RequireComparableGraphEqual[Key Ordered]( // // The order of the input ExpectedNodes does not matter, and the order of // the outbound Keys does not matter. -func RequireGraphEqual[Key Ordered, Value any]( +func RequireGraphEqual[Key cmp.Ordered, Value any]( t *testing.T, expected []ExpectedNode[Key], graph *dag.Graph[Key, Value], @@ -77,7 +68,7 @@ func RequireGraphEqual[Key Ordered, Value any]( require.Equal(t, normalizeExpectedNodes(expected), normalizeExpectedNodes(actual)) } -func normalizeExpectedNodes[Key Ordered](expectedNodes []ExpectedNode[Key]) []ExpectedNode[Key] { +func normalizeExpectedNodes[Key cmp.Ordered](expectedNodes []ExpectedNode[Key]) []ExpectedNode[Key] { if expectedNodes == nil { return []ExpectedNode[Key]{} } @@ -95,7 +86,7 @@ func normalizeExpectedNodes[Key Ordered](expectedNodes []ExpectedNode[Key]) []Ex return c } -func normalizeKeys[Key Ordered](keys []Key) []Key { +func normalizeKeys[Key cmp.Ordered](keys []Key) []Key { if keys == nil { return []Key{} } diff --git a/private/pkg/oauth2/client.go b/private/pkg/oauth2/client.go index 79a9fed85b..4f36a18fa7 100644 --- a/private/pkg/oauth2/client.go +++ b/private/pkg/oauth2/client.go @@ -29,13 +29,6 @@ import ( "go.uber.org/multierr" ) -var ( - // ErrUnsupported is returned when we receive an unsupported response from the server. - // - // TODO(go1.21): replace by errors.ErrUnsupported once it is available. - ErrUnsupported = errors.New("unsupported operation") -) - const ( defaultPollingInterval = 5 * time.Second incrementPollingInterval = 5 * time.Second @@ -239,7 +232,7 @@ func parseJSONResponse(response *http.Response, payload any) error { return fmt.Errorf("oauth2: failed to read response body: %w", err) } if contentType, _, _ := mime.ParseMediaType(response.Header.Get("Content-Type")); contentType != "application/json" { - return fmt.Errorf("oauth2: %w: %d %s", ErrUnsupported, response.StatusCode, body) + return fmt.Errorf("oauth2: %w: %d %s", errors.ErrUnsupported, response.StatusCode, body) } if err := json.Unmarshal(body, &payload); err != nil { return fmt.Errorf("oauth2: failed to unmarshal response: %w: %s", err, body) diff --git a/private/pkg/oauth2/client_test.go b/private/pkg/oauth2/client_test.go index c027345b70..9558beea83 100644 --- a/private/pkg/oauth2/client_test.go +++ b/private/pkg/oauth2/client_test.go @@ -16,6 +16,7 @@ package oauth2 import ( "context" + "errors" "fmt" "io" "net/http" @@ -87,7 +88,7 @@ func TestRegisterDevice(t *testing.T) { Body: io.NopCloser(strings.NewReader(`not implemented`)), }, nil }, - err: fmt.Errorf("oauth2: %w: 501 not implemented", ErrUnsupported), + err: fmt.Errorf("oauth2: %w: 501 not implemented", errors.ErrUnsupported), }} for _, test := range tests { test := test diff --git a/private/pkg/protoversion/package_version.go b/private/pkg/protoversion/package_version.go index 61ff584e13..2395c3f8fa 100644 --- a/private/pkg/protoversion/package_version.go +++ b/private/pkg/protoversion/package_version.go @@ -204,7 +204,7 @@ func getAlphaBetaMajorPatch(remainder string, minMajorVersionNumber int) (int, i return major, 0, true } -func getNumber(s string, min int) (int, bool) { +func getNumber(s string, minimum int) (int, bool) { if s == "" { return 0, false } @@ -212,7 +212,7 @@ func getNumber(s string, min int) (int, bool) { if err != nil { return 0, false } - if value < int64(min) { + if value < int64(minimum) { return 0, false } return int(value), true diff --git a/private/pkg/slicesext/slicesext.go b/private/pkg/slicesext/slicesext.go index e87621a1f0..fc787d91ec 100644 --- a/private/pkg/slicesext/slicesext.go +++ b/private/pkg/slicesext/slicesext.go @@ -46,21 +46,13 @@ package slicesext import ( + "cmp" "fmt" + "slices" "sort" "strings" ) -// Ordered matches cmp.Ordered until we only support Go versions >= 1.21. -// -// TODO FUTURE: remove and replace with cmp.Ordered when we only support Go versions >= 1.21. -type Ordered interface { - ~int | ~int8 | ~int16 | ~int32 | ~int64 | - ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | - ~float32 | ~float64 | - ~string -} - // Indexed is a value that had an index within a slice. type Indexed[T any] struct { Value T @@ -214,25 +206,6 @@ func Concat[S ~[]E, E any](slices ...S) S { return newslice } -// Equal reports whether two slices are equal: the same length and all -// elements equal. If the lengths are different, Equal returns false. -// Otherwise, the elements are compared in increasing index order, and the -// comparison stops at the first unequal pair. -// Floating point NaNs are not considered equal. -// -// TODO FUTURE: Delete this in favor of slices.Equal when we are >1.21. -func Equal[S ~[]E, E comparable](s1, s2 S) bool { - if len(s1) != len(s2) { - return false - } - for i := range s1 { - if s1[i] != s2[i] { - return false - } - } - return true -} - // ToStructMap converts the slice to a map with struct{} values. func ToStructMap[T comparable](s []T) map[T]struct{} { m := make(map[T]struct{}, len(s)) @@ -368,15 +341,9 @@ func IndexedToSortedValues[T any](s []Indexed[T]) []T { } // MapKeysToSortedSlice converts the map's keys to a sorted slice. -func MapKeysToSortedSlice[M ~map[K]V, K Ordered, V any](m M) []K { +func MapKeysToSortedSlice[M ~map[K]V, K cmp.Ordered, V any](m M) []K { s := MapKeysToSlice(m) - // TODO FUTURE: Replace with slices.Sort when we only support Go versions >= 1.21. - sort.Slice( - s, - func(i int, j int) bool { - return s[i] < s[j] - }, - ) + slices.Sort(s) return s } @@ -393,15 +360,9 @@ func MapKeysToSlice[K comparable, V any](m map[K]V) []K { // // Duplicate values will be added. This should generally be used // in cases where you know there is a 1-1 mapping from K to V. -func MapValuesToSortedSlice[K comparable, V Ordered](m map[K]V) []V { +func MapValuesToSortedSlice[K comparable, V cmp.Ordered](m map[K]V) []V { s := MapValuesToSlice(m) - // TODO FUTURE: Replace with slices.Sort when we only support Go versions >= 1.21. - sort.Slice( - s, - func(i int, j int) bool { - return s[i] < s[j] - }, - ) + slices.Sort(s) return s } @@ -418,7 +379,7 @@ func MapValuesToSlice[K comparable, V any](m map[K]V) []V { } // ToUniqueSorted returns a sorted copy of s with no duplicates. -func ToUniqueSorted[S ~[]T, T Ordered](s S) S { +func ToUniqueSorted[S ~[]T, T cmp.Ordered](s S) S { return MapKeysToSortedSlice(ToStructMap(s)) } diff --git a/private/pkg/storage/map.go b/private/pkg/storage/map.go index cfede8b721..675fc50031 100644 --- a/private/pkg/storage/map.go +++ b/private/pkg/storage/map.go @@ -232,8 +232,9 @@ func newMapWriteBucketCloser( mapper Mapper, ) *mapWriteBucketCloser { return &mapWriteBucketCloser{ - delegate: delegate, - mapper: mapper, + delegate: delegate, + closeFunc: closeFunc, + mapper: mapper, } } diff --git a/private/pkg/syncext/syncext.go b/private/pkg/syncext/syncext.go index b06a5aeb46..68a127bd14 100644 --- a/private/pkg/syncext/syncext.go +++ b/private/pkg/syncext/syncext.go @@ -17,73 +17,6 @@ package syncext import "sync" -// OnceValue returns a function that invokes f only once and returns the value -// returned by f. The returned function may be called concurrently. -// -// If f panics, the returned function will panic with the same value on every call. -// -// TODO FUTURE: This is directly copied from 1.21 source, remove when no longer need <1.21. -func OnceValue[T any](f func() T) func() T { - var ( - once sync.Once - valid bool - p any - result T - ) - g := func() { - defer func() { - p = recover() - if !valid { - panic(p) - } - }() - result = f() - f = nil - valid = true - } - return func() T { - once.Do(g) - if !valid { - panic(p) - } - return result - } -} - -// OnceValues returns a function that invokes f only once and returns the values -// returned by f. The returned function may be called concurrently. -// -// If f panics, the returned function will panic with the same value on every call. -// -// TODO FUTURE: This is directly copied from 1.21 source, remove when no longer need <1.21. -func OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2) { - var ( - once sync.Once - valid bool - p any - r1 T1 - r2 T2 - ) - g := func() { - defer func() { - p = recover() - if !valid { - panic(p) - } - }() - r1, r2 = f() - f = nil - valid = true - } - return func() (T1, T2) { - once.Do(g) - if !valid { - panic(p) - } - return r1, r2 - } -} - // OnceValues3 returns a function that invokes f only once and returns the values // returned by f. The returned function may be called concurrently. // diff --git a/private/pkg/thread/thread.go b/private/pkg/thread/thread.go index 103a02af19..f4e37e1107 100644 --- a/private/pkg/thread/thread.go +++ b/private/pkg/thread/thread.go @@ -68,6 +68,11 @@ func Parallelize(ctx context.Context, jobs []func(context.Context) error, option if multiplier < 1 { multiplier = 1 } + var cancel context.CancelFunc + if parallelizeOptions.cancelOnFailure { + ctx, cancel = context.WithCancel(ctx) + defer cancel() + } semaphoreC := make(chan struct{}, Parallelism()*multiplier) var retErr error var wg sync.WaitGroup @@ -100,8 +105,8 @@ func Parallelize(ctx context.Context, jobs []func(context.Context) error, option lock.Lock() retErr = multierr.Append(retErr, err) lock.Unlock() - if parallelizeOptions.cancel != nil { - parallelizeOptions.cancel() + if cancel != nil { + cancel() } } // This will never block. @@ -129,17 +134,17 @@ func ParallelizeWithMultiplier(multiplier int) ParallelizeOption { } } -// ParallelizeWithCancel returns a new ParallelizeOption that will call the -// given context.CancelFunc if any job fails. -func ParallelizeWithCancel(cancel context.CancelFunc) ParallelizeOption { +// ParallelizeWithCancelOnFailure returns a new ParallelizeOption that will attempt +// to cancel all other jobs via context cancellation if any job fails. +func ParallelizeWithCancelOnFailure() ParallelizeOption { return func(parallelizeOptions *parallelizeOptions) { - parallelizeOptions.cancel = cancel + parallelizeOptions.cancelOnFailure = true } } type parallelizeOptions struct { - multiplier int - cancel context.CancelFunc + multiplier int + cancelOnFailure bool } func newParallelizeOptions() *parallelizeOptions {