diff options
Diffstat (limited to 'vendor/github.com/vektra')
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/.mockery.yaml | 11 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/Dockerfile | 2 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/README.md | 23 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/Taskfile.yml | 4 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/cmd/mockery.go | 12 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/codecov.yml | 6 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/go.work | 4 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/go.work.sum | 15 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/mkdocs.yml | 8 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/pkg/config/config.go | 55 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/pkg/generator.go | 83 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/pkg/outputter.go | 12 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/pkg/parse.go | 99 | ||||
| -rw-r--r-- | vendor/github.com/vektra/mockery/v2/pkg/walker.go | 2 |
14 files changed, 231 insertions, 105 deletions
diff --git a/vendor/github.com/vektra/mockery/v2/.mockery.yaml b/vendor/github.com/vektra/mockery/v2/.mockery.yaml index 2559bb86d..ffeed52b2 100644 --- a/vendor/github.com/vektra/mockery/v2/.mockery.yaml +++ b/vendor/github.com/vektra/mockery/v2/.mockery.yaml @@ -41,6 +41,17 @@ packages: config: with-expecter: True unroll-variadic: False + # Replace generic params with a new constraint and a new fixed value + ReplaceGeneric: + config: + replace-type: + - github.com/vektra/mockery/v2/pkg/fixtures.ReplaceGeneric[-TImport]=github.com/vektra/mockery/v2/pkg/fixtures/redefined_type_b.B + - github.com/vektra/mockery/v2/pkg/fixtures.ReplaceGeneric[TConstraint]=github.com/vektra/mockery/v2/pkg/fixtures/constraints.String + # Replace a generic param with the parent type + ReplaceGenericSelf: + config: + replace-type: + - github.com/vektra/mockery/v2/pkg/fixtures.ReplaceGenericSelf[-T]=github.com/vektra/mockery/v2/pkg/fixtures.*ReplaceGenericSelf github.com/vektra/mockery/v2/pkg/fixtures/recursive_generation: config: recursive: True diff --git a/vendor/github.com/vektra/mockery/v2/Dockerfile b/vendor/github.com/vektra/mockery/v2/Dockerfile index 5ef333249..ee64734bc 100644 --- a/vendor/github.com/vektra/mockery/v2/Dockerfile +++ b/vendor/github.com/vektra/mockery/v2/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22-alpine as builder +FROM golang:1.23-alpine as builder RUN apk --update add --no-cache gcc musl-dev diff --git a/vendor/github.com/vektra/mockery/v2/README.md b/vendor/github.com/vektra/mockery/v2/README.md index 7249166d7..bf62b714b 100644 --- a/vendor/github.com/vektra/mockery/v2/README.md +++ b/vendor/github.com/vektra/mockery/v2/README.md @@ -26,29 +26,6 @@ $ task test task: [test] go test -v -coverprofile=coverage.txt ./... ``` -Development Efforts -------------------- - -### v1 - -v1 is the original version of the software, and is no longer supported. - -### v2 - -`mockery` is currently in v2, which originally included cosmetic and configuration improvements over v1, but also implements a number of quality-of-life additions. - -### v3 - -[v3](https://github.com/vektra/mockery/projects/3) will include a ground-up overhaul of the entire codebase and will completely change how mockery works internally and externally. The highlights of the project are: -- Moving towards a package-based model instead of a file-based model. `mockery` currently iterates over every file in a project and calls `package.Load` on each one, which is time-consuming. Moving towards a model where the entire package is loaded at once will dramatically reduce runtime, and will simplify logic. Additionally, supporting only a single mode of operation (package mode) will greatly increase the intuitiveness of the software. -- Configuration-driven generation. `v3` will be entirely driven by configuration, meaning: - * You specify the packages you want mocked, instead of relying on it auto-discovering your package. Auto-discovery in theory sounds great, but in practice it leads to a great amount of complexity for very little benefit. - * Package- or interface-specific overrides can be given that change mock generation settings on a granular level. This will allow your mocks to be generated in a heterogeneous manner, and will be made explicit by YAML configuration. - - Proper error reporting. Errors across the board will be done in accordance with modern Golang practices - - Variables in generated mocks will be given meaningful names. - - - Stargazers ---------- diff --git a/vendor/github.com/vektra/mockery/v2/Taskfile.yml b/vendor/github.com/vektra/mockery/v2/Taskfile.yml index 5e11bb39a..8c6ff4c0c 100644 --- a/vendor/github.com/vektra/mockery/v2/Taskfile.yml +++ b/vendor/github.com/vektra/mockery/v2/Taskfile.yml @@ -13,7 +13,7 @@ tasks: - "**/*.go" cmds: - go fmt ./... - + mocks: desc: generate new mocks from scratch deps: [mocks.remove, mocks.generate] @@ -21,7 +21,7 @@ tasks: mocks.remove: desc: remove all mock files cmds: - - find . -name '*_mock.go' | xargs rm + - find . -name '*_mock.go' | xargs -r rm - rm -rf mocks/ mocks.generate: diff --git a/vendor/github.com/vektra/mockery/v2/cmd/mockery.go b/vendor/github.com/vektra/mockery/v2/cmd/mockery.go index da748314d..360dea68d 100644 --- a/vendor/github.com/vektra/mockery/v2/cmd/mockery.go +++ b/vendor/github.com/vektra/mockery/v2/cmd/mockery.go @@ -83,6 +83,7 @@ func NewRootCmd() *cobra.Command { pFlags.Bool("exported", false, "Generates public mocks for private interfaces.") pFlags.Bool("with-expecter", false, "Generate expecter utility around mock's On, Run and Return methods with explicit types. This option is NOT compatible with -unroll-variadic=false") pFlags.StringArray("replace-type", nil, "Replace types") + pFlags.Bool("disable-func-mocks", false, "Disable generation of function mocks.") if err := viperCfg.BindPFlags(pFlags); err != nil { panic(fmt.Sprintf("failed to bind PFlags: %v", err)) @@ -238,17 +239,12 @@ func (r *RootApp) Run() error { if err != nil { return fmt.Errorf("failed to get package from config: %w", err) } - parser := pkg.NewParser(buildTags) + parser := pkg.NewParser(buildTags, pkg.ParserDisableFuncMocks(r.Config.DisableFuncMocks)) if err := parser.ParsePackages(ctx, configuredPackages); err != nil { log.Error().Err(err).Msg("unable to parse packages") return err } - log.Info().Msg("done parsing, loading") - if err := parser.Load(); err != nil { - log.Err(err).Msgf("failed to load parser") - return nil - } log.Info().Msg("done loading, visiting interface nodes") for _, iface := range parser.Interfaces() { ifaceLog := log. @@ -269,7 +265,7 @@ func (r *RootApp) Run() error { } ifaceLog.Debug().Msg("config specifies to generate this interface") - outputter := pkg.NewOutputter(&r.Config, boilerplate, true) + outputter := pkg.NewOutputter(&r.Config, boilerplate, r.Config.DryRun) if err := outputter.Generate(ifaceCtx, iface); err != nil { return err } @@ -316,7 +312,7 @@ func (r *RootApp) Run() error { if err != nil { return stackerr.NewStackErrf(err, "Failed to create profile file") } - + defer f.Close() if err := pprof.StartCPUProfile(f); err != nil { return fmt.Errorf("failed to start CPU profile: %w", err) } diff --git a/vendor/github.com/vektra/mockery/v2/codecov.yml b/vendor/github.com/vektra/mockery/v2/codecov.yml index 465cfd701..77f5dee69 100644 --- a/vendor/github.com/vektra/mockery/v2/codecov.yml +++ b/vendor/github.com/vektra/mockery/v2/codecov.yml @@ -1,11 +1,11 @@ coverage: precision: 5 round: down - range: "65...100" + range: "00...100" status: patch: default: - target: 65% - threshold: 5% + target: 40% + threshold: 35% base: auto diff --git a/vendor/github.com/vektra/mockery/v2/go.work b/vendor/github.com/vektra/mockery/v2/go.work index 59b494ce2..baf732d14 100644 --- a/vendor/github.com/vektra/mockery/v2/go.work +++ b/vendor/github.com/vektra/mockery/v2/go.work @@ -1,6 +1,6 @@ -go 1.21 +go 1.22 -toolchain go1.21.0 +toolchain go1.22.0 use ( . diff --git a/vendor/github.com/vektra/mockery/v2/go.work.sum b/vendor/github.com/vektra/mockery/v2/go.work.sum index fac3c7ce3..858e33015 100644 --- a/vendor/github.com/vektra/mockery/v2/go.work.sum +++ b/vendor/github.com/vektra/mockery/v2/go.work.sum @@ -290,7 +290,6 @@ github.com/armon/go-metrics v0.4.0/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/census-instrumentation/opencensus-proto v0.3.0 h1:t/LhUZLVitR1Ow2YOnduCsavhwFUklBMoGVYUCqmCqk= @@ -320,7 +319,6 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534 h1:rtAn27wIbmOGUs7RIbVgPEjb31ehTVniDwPGXyMxm5U= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/cristalhq/acmd v0.11.1 h1:DJ4fh2Pv0nPKmqT646IU/0Vh5FNdGblxvF+3/W3NAUI= github.com/cristalhq/acmd v0.11.1/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= @@ -341,13 +339,11 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk= github.com/go-kit/log v0.1.0 h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ= github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= -github.com/go-toolsmith/pkgload v1.2.2/go.mod h1:R2hxLNRKuAsiXCo2i5J6ZQPhnPMOVtU+f0arbFPWCus= github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -397,7 +393,6 @@ github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+ github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8 h1:tlyzajkF3030q6M8SvmJSemC9DTHL/xaMa18b65+JM4= github.com/gookit/color v1.5.2 h1:uLnfXcaFjlrDnQDT+NCBcfhrXqYTx/rcCa6xn01Y8yI= github.com/gookit/color v1.5.2/go.mod h1:w8h4bGiHeeBpvQVePTutdbERIUf3oJE5lZ8HM0UgXyg= -github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Repi5x3CuviD3dgAZaBU= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= @@ -492,8 +487,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/mozilla/tls-observatory v0.0.0-20210609171429-7bc42856d2e5 h1:0KqC6/sLy7fDpBdybhVkkv4Yz+PmB7c9Dz9z3dLW804= github.com/mozilla/tls-observatory v0.0.0-20210609171429-7bc42856d2e5/go.mod h1:FUqVoUPHSEdDR0MnFM3Dh8AU0pZHLXUD127SAJGER/s= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= -github.com/onsi/ginkgo/v2 v2.8.0/go.mod h1:6JsQiECmxCa3V5st74AL/AmsV482EDdVrGaVW6z3oYU= -github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI= github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -571,7 +564,6 @@ go.opentelemetry.io/proto/otlp v0.7.0 h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzc go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= @@ -587,8 +579,6 @@ golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDA golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -624,8 +614,6 @@ golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 h1:nt+Q6cXKz4MosCSpnbMtqiQ8Oz0pxTef2B4Vca2lvfk= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -676,8 +664,6 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= @@ -786,6 +772,7 @@ google.golang.org/grpc v1.52.0/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5v google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= diff --git a/vendor/github.com/vektra/mockery/v2/mkdocs.yml b/vendor/github.com/vektra/mockery/v2/mkdocs.yml index 2c59e5767..4959ac1de 100644 --- a/vendor/github.com/vektra/mockery/v2/mkdocs.yml +++ b/vendor/github.com/vektra/mockery/v2/mkdocs.yml @@ -83,10 +83,12 @@ extra: property: G-0ZGMQGZGRN plugins: +- glightbox - mike: alias_type: symlink canonical_version: latest -- glightbox -- social -- search - open-in-new-tab +- search +- social +- typeset: + enabled: true diff --git a/vendor/github.com/vektra/mockery/v2/pkg/config/config.go b/vendor/github.com/vektra/mockery/v2/pkg/config/config.go index 13d457f51..dee932c75 100644 --- a/vendor/github.com/vektra/mockery/v2/pkg/config/config.go +++ b/vendor/github.com/vektra/mockery/v2/pkg/config/config.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "os" + "path/filepath" "reflect" "regexp" "strings" @@ -40,6 +41,7 @@ type Config struct { Cpuprofile string `mapstructure:"cpuprofile"` Dir string `mapstructure:"dir"` DisableConfigSearch bool `mapstructure:"disable-config-search"` + DisableFuncMocks bool `mapstructure:"disable-func-mocks"` DisableVersionString bool `mapstructure:"disable-version-string"` DryRun bool `mapstructure:"dry-run"` ExcludeRegex string `mapstructure:"exclude-regex"` @@ -528,6 +530,21 @@ func isAutoGenerated(path *pathlib.Path) (bool, error) { return false, nil } +func shouldExcludeModule(ctx context.Context, root *pathlib.Path, goModPath *pathlib.Path) (bool, error) { + log := zerolog.Ctx(ctx) + relative, err := goModPath.RelativeTo(root) + if err != nil { + return false, stackerr.NewStackErrf(err, "determining distance from search root") + } + + if len(relative.Parts()) != 1 { + log.Debug().Msg("skipping sub-module") + return true, nil + } + log.Debug().Int("parts_len", len(relative.Parts())).Str("parts", fmt.Sprintf("%v", relative.Parts())).Msg("not skipping module as this is the root path") + return false, nil +} + func (c *Config) subPackages( ctx context.Context, pkgPath string, @@ -587,16 +604,14 @@ func (c *Config) subPackages( pathLog.Debug().Msg("path contains go.mod file") // Check if our current depth is 0. We do this to skip sub-modules, but not // the root module. - relative, err := path.RelativeTo(searchRoot) + shouldExclude, err := shouldExcludeModule(ctx, searchRoot, path) if err != nil { - return stackerr.NewStackErrf(err, "determining distance from search root") + return err } - if len(relative.Parts()) != 1 { - pathLog.Debug().Msg("skipping sub-module") + if shouldExclude { return pathlib.ErrWalkSkipSubtree } - pathLog.Debug().Int("parts_len", len(relative.Parts())).Str("parts", fmt.Sprintf("%v", relative.Parts())).Msg("not skipping module as this is the root path") } _, haveVisitedDir := visitedDirs[path.Parent().String()] @@ -614,7 +629,22 @@ func (c *Config) subPackages( } } - pathLog.Debug().Msg("subdirectory has a .go file, adding this path to packages config") + pathLog.Debug().Msg("subdirectory has a .go file") + goModPath := path.Parent().Join("go.mod") + goModExists, err := goModPath.Exists() + if err != nil { + pathLog.Err(err).Msg("failed to determine if go.mod exists") + return err + } + if goModExists { + shouldExclude, err := shouldExcludeModule(ctx, searchRoot, goModPath) + if err != nil { + return err + } + if shouldExclude { + return pathlib.ErrWalkSkipSubtree + } + } subdirectoriesWithGoFiles = append(subdirectoriesWithGoFiles, path.Parent()) visitedDirs[path.Parent().String()] = nil } @@ -633,7 +663,7 @@ func (c *Config) subPackages( return nil, fmt.Errorf("failed to make subroot relative to root: %w", err) } absolutePackageName := packageRootName.Join(relativeFilesystemPath.Parts()...) - subPackages = append(subPackages, absolutePackageName.String()) + subPackages = append(subPackages, filepath.ToSlash(absolutePackageName.String())) } return subPackages, nil @@ -679,8 +709,15 @@ func (c *Config) discoverRecursivePackages(ctx context.Context) error { subPkgCtx := subPkgLog.WithContext(pkgCtx) if len(conf.Exclude) > 0 { - p := pathlib.NewPath(subPkg) - relativePath, err := p.RelativeToStr(pkgPath) + // pass in the forward-slash as this is a package and the os.PathSeparator + // cannot be used here as it fails on windows. + p := pathlib.NewPath(subPkg, pathlib.PathWithSeperator("/")) + relativePath, err := p.RelativeTo( + pathlib.NewPath( + pkgPath, pathlib.PathWithAfero(p.Fs()), + pathlib.PathWithSeperator("/"), + ), + ) if err != nil { return stackerr.NewStackErrf(err, "failed to get path for %s relative to %s", subPkg, pkgPath) } diff --git a/vendor/github.com/vektra/mockery/v2/pkg/generator.go b/vendor/github.com/vektra/mockery/v2/pkg/generator.go index 85ce89ee5..2941b48b7 100644 --- a/vendor/github.com/vektra/mockery/v2/pkg/generator.go +++ b/vendor/github.com/vektra/mockery/v2/pkg/generator.go @@ -25,7 +25,7 @@ import ( const mockConstructorParamTypeNamePrefix = "mockConstructorTestingT" -var invalidIdentifierChar = regexp.MustCompile("[^[:digit:][:alpha:]_]") +var invalidIdentifierChar = regexp.MustCompile("^[[:digit:]]|[^[:digit:][:alpha:]_]") func DetermineOutputPackageName( interfaceFileName string, @@ -196,7 +196,7 @@ func (g *Generator) addPackageImportWithName(ctx context.Context, path, name str log := zerolog.Ctx(ctx) replaced := false g.checkReplaceType(ctx, func(from *replaceType, to *replaceType) bool { - if o != nil && path == from.pkg && (from.typ == "" || o.Name() == from.typ) { + if o != nil && path == from.pkg && (from.typ == "" || o.Name() == from.typ || o.Name() == from.param) { log.Debug().Str("from", path).Str("to", to.pkg).Msg("changing package path") replaced = true path = to.pkg @@ -326,10 +326,32 @@ func (g *Generator) getTypeConstraintString(ctx context.Context) string { return "" } qualifiedParams := make([]string, 0, tp.Len()) +param: for i := 0; i < tp.Len(); i++ { param := tp.At(i) - qualifiedParams = append(qualifiedParams, fmt.Sprintf("%s %s", param.String(), g.renderType(ctx, param.Constraint()))) + str := param.String() + typ := g.renderType(ctx, param.Constraint()) + + for _, t := range g.replaceTypeCache { + if str == t.from.param { + // Skip removed generic constraints + if t.from.rmvParam { + continue param + } + + // Import replaced generic constraints + pkg := g.addPackageImportWithName(ctx, t.to.pkg, t.to.alias, param.Obj()) + typ = pkg + "." + t.to.typ + } + } + + qualifiedParams = append(qualifiedParams, fmt.Sprintf("%s %s", str, typ)) + } + + if len(qualifiedParams) == 0 { + return "" } + return fmt.Sprintf("[%s]", strings.Join(qualifiedParams, ", ")) } @@ -342,8 +364,21 @@ func (g *Generator) getInstantiatedTypeString() string { return "" } params := make([]string, 0, tp.Len()) +param: for i := 0; i < tp.Len(); i++ { - params = append(params, tp.At(i).String()) + str := tp.At(i).String() + + // Skip replaced generic types + for _, t := range g.replaceTypeCache { + if str == t.from.param && t.from.rmvParam { + continue param + } + } + + params = append(params, str) + } + if len(params) == 0 { + return "" } return fmt.Sprintf("[%s]", strings.Join(params, ", ")) } @@ -475,7 +510,25 @@ func (g *Generator) renderType(ctx context.Context, typ types.Type) string { return fmt.Sprintf("%s[%s]", name, strings.Join(args, ",")) case *types.TypeParam: if t.Constraint() != nil { - return t.Obj().Name() + name := t.Obj().Name() + pkg := "" + + g.checkReplaceType(ctx, func(from *replaceType, to *replaceType) bool { + // Replace with the new type if it is being removed as a constraint + if t.Obj().Pkg().Path() == from.pkg && name == from.param && from.rmvParam { + name = to.typ + if to.pkg != from.pkg { + pkg = g.addPackageImport(ctx, t.Obj().Pkg(), t.Obj()) + } + return false + } + return true + }) + + if pkg != "" { + return pkg + "." + name + } + return name } return g.getPackageScopedType(ctx, t.Obj()) case *types.Basic: @@ -506,7 +559,7 @@ func (g *Generator) renderType(ctx context.Context, typ types.Type) string { return fmt.Sprintf( "func(%s)(%s)", g.renderTypeTuple(ctx, t.Params(), t.Variadic()), - g.renderTypeTuple(ctx, t.Results(), t.Variadic()), + g.renderTypeTuple(ctx, t.Results(), false), ) } case *types.Map: @@ -677,7 +730,7 @@ func (g *Generator) genList(ctx context.Context, list *types.Tuple, variadic boo params.Params = append(params.Params, fmt.Sprintf("%s %s", pname, ts)) params.Nilable = append(params.Nilable, isNillable(v.Type())) - if strings.Contains(ts, "...") { + if variadic && i == list.Len()-1 { params.ParamsIntf = append(params.ParamsIntf, fmt.Sprintf("%s ...interface{}", pname)) } else { params.ParamsIntf = append(params.ParamsIntf, fmt.Sprintf("%s interface{}", pname)) @@ -1088,9 +1141,11 @@ func resolveCollision(names []string, variable string) string { } type replaceType struct { - alias string - pkg string - typ string + alias string + pkg string + typ string + param string + rmvParam bool } type replaceTypeItem struct { @@ -1105,6 +1160,14 @@ func parseReplaceType(t string) *replaceType { ret.alias = r[0] t = r[1] } + + // Match type parameter substitution + match := regexp.MustCompile(`\[(.*?)\]$`).FindStringSubmatch(t) + if len(match) >= 2 { + ret.param, ret.rmvParam = strings.CutPrefix(match[1], "-") + t = strings.ReplaceAll(t, match[0], "") + } + lastDot := strings.LastIndex(t, ".") lastSlash := strings.LastIndex(t, "/") if lastDot == -1 || (lastSlash > -1 && lastDot < lastSlash) { diff --git a/vendor/github.com/vektra/mockery/v2/pkg/outputter.go b/vendor/github.com/vektra/mockery/v2/pkg/outputter.go index 1960be9bf..e3f916fc1 100644 --- a/vendor/github.com/vektra/mockery/v2/pkg/outputter.go +++ b/vendor/github.com/vektra/mockery/v2/pkg/outputter.go @@ -210,6 +210,7 @@ func parseConfigTemplates(ctx context.Context, c *config.Config, iface *Interfac data := struct { InterfaceDir string InterfaceDirRelative string + InterfaceFile string InterfaceName string InterfaceNameCamel string InterfaceNameLowerCamel string @@ -222,6 +223,7 @@ func parseConfigTemplates(ctx context.Context, c *config.Config, iface *Interfac }{ InterfaceDir: filepath.Dir(iface.FileName), InterfaceDirRelative: interfaceDirRelative, + InterfaceFile: iface.FileName, InterfaceName: iface.Name, // Deprecated: All custom case variables of InterfaceName will be removed in the next major version // Use the template functions instead @@ -351,13 +353,19 @@ func (m *Outputter) Generate(ctx context.Context, iface *Interface) error { return err } + // Log where the file would be written to before checking whether to create the directories and files outputPath := pathlib.NewPath(interfaceConfig.Dir).Join(interfaceConfig.FileName) + fileLog := log.With().Stringer(logging.LogKeyFile, outputPath).Logger() + fileLog.Info().Msg("writing to file") + + if m.dryRun { + continue + } + if err := outputPath.Parent().MkdirAll(); err != nil { return stackerr.NewStackErrf(err, "failed to mkdir parents of: %v", outputPath) } - fileLog := log.With().Stringer(logging.LogKeyFile, outputPath).Logger() - fileLog.Info().Msg("writing to file") file, err := outputPath.OpenFile(os.O_RDWR | os.O_CREATE | os.O_TRUNC) if err != nil { return stackerr.NewStackErrf(err, "failed to open output file for mock: %v", outputPath) diff --git a/vendor/github.com/vektra/mockery/v2/pkg/parse.go b/vendor/github.com/vektra/mockery/v2/pkg/parse.go index e85077a96..81b08de64 100644 --- a/vendor/github.com/vektra/mockery/v2/pkg/parse.go +++ b/vendor/github.com/vektra/mockery/v2/pkg/parse.go @@ -16,11 +16,18 @@ import ( "golang.org/x/tools/go/packages" ) -type parserEntry struct { - fileName string - pkg *packages.Package - syntax *ast.File - interfaces []string +type fileEntry struct { + fileName string + pkg *packages.Package + syntax *ast.File + interfaces []string + disableFuncMocks bool +} + +func (f *fileEntry) ParseInterfaces(ctx context.Context) { + nv := NewNodeVisitor(ctx, f.disableFuncMocks) + ast.Walk(nv, f.syntax) + f.interfaces = nv.DeclaredInterfaces() } type packageLoadEntry struct { @@ -29,14 +36,20 @@ type packageLoadEntry struct { } type Parser struct { - entries []*parserEntry - entriesByFileName map[string]*parserEntry + files []*fileEntry + entriesByFileName map[string]*fileEntry parserPackages []*types.Package conf packages.Config packageLoadCache map[string]packageLoadEntry + disableFuncMocks bool } -func NewParser(buildTags []string) *Parser { +func ParserDisableFuncMocks(disable bool) func(*Parser) { + return func(p *Parser) { + p.disableFuncMocks = disable + } +} +func NewParser(buildTags []string, opts ...func(*Parser)) *Parser { var conf packages.Config conf.Mode = packages.NeedTypes | packages.NeedTypesSizes | @@ -50,12 +63,16 @@ func NewParser(buildTags []string) *Parser { if len(buildTags) > 0 { conf.BuildFlags = []string{"-tags", strings.Join(buildTags, ",")} } - return &Parser{ + p := &Parser{ parserPackages: make([]*types.Package, 0), - entriesByFileName: map[string]*parserEntry{}, + entriesByFileName: map[string]*fileEntry{}, conf: conf, packageLoadCache: map[string]packageLoadEntry{}, } + for _, opt := range opts { + opt(p) + } + return p } func (p *Parser) loadPackages(fpath string) ([]*packages.Package, error) { @@ -86,18 +103,22 @@ func (p *Parser) ParsePackages(ctx context.Context, packageNames []string) error Str("package", pkg.PkgPath). Str("file", file). Msgf("found file") - entry := parserEntry{ - fileName: file, - pkg: pkg, - syntax: pkg.Syntax[fileIdx], + entry := fileEntry{ + fileName: file, + pkg: pkg, + syntax: pkg.Syntax[fileIdx], + disableFuncMocks: p.disableFuncMocks, } - p.entries = append(p.entries, &entry) + entry.ParseInterfaces(ctx) + p.files = append(p.files, &entry) p.entriesByFileName[file] = &entry } } return nil } +// DEPRECATED: Parse is part of the deprecated, legacy mockery behavior. This is not +// used when the packages feature is enabled. func (p *Parser) Parse(ctx context.Context, path string) error { // To support relative paths to mock targets w/ vendor deps, we need to provide eventual // calls to build.Context.Import with an absolute path. It needs to be absolute because @@ -164,12 +185,12 @@ func (p *Parser) Parse(ctx context.Context, path string) error { if _, ok := p.entriesByFileName[f]; ok { continue } - entry := parserEntry{ + entry := fileEntry{ fileName: f, pkg: pkg, syntax: pkg.Syntax[idx], } - p.entries = append(p.entries, &entry) + p.files = append(p.files, &entry) p.entriesByFileName[f] = &entry } } @@ -177,17 +198,15 @@ func (p *Parser) Parse(ctx context.Context, path string) error { return nil } -func (p *Parser) Load() error { - for _, entry := range p.entries { - nv := NewNodeVisitor() - ast.Walk(nv, entry.syntax) - entry.interfaces = nv.DeclaredInterfaces() +func (p *Parser) Load(ctx context.Context) error { + for _, entry := range p.files { + entry.ParseInterfaces(ctx) } return nil } func (p *Parser) Find(name string) (*Interface, error) { - for _, entry := range p.entries { + for _, entry := range p.files { for _, iface := range entry.interfaces { if iface == name { list := p.packageInterfaces(entry.pkg.Types, entry.fileName, []string{name}, nil) @@ -202,7 +221,7 @@ func (p *Parser) Find(name string) (*Interface, error) { func (p *Parser) Interfaces() []*Interface { ifaces := make(sortableIFaceList, 0) - for _, entry := range p.entries { + for _, entry := range p.files { declaredIfaces := entry.interfaces ifaces = p.packageInterfaces(entry.pkg.Types, entry.fileName, declaredIfaces, ifaces) } @@ -315,11 +334,15 @@ func (s sortableIFaceList) Less(i, j int) bool { type NodeVisitor struct { declaredInterfaces []string + disableFuncMocks bool + ctx context.Context } -func NewNodeVisitor() *NodeVisitor { +func NewNodeVisitor(ctx context.Context, disableFuncMocks bool) *NodeVisitor { return &NodeVisitor{ declaredInterfaces: make([]string, 0), + disableFuncMocks: disableFuncMocks, + ctx: ctx, } } @@ -327,12 +350,34 @@ func (nv *NodeVisitor) DeclaredInterfaces() []string { return nv.declaredInterfaces } +func (nv *NodeVisitor) add(ctx context.Context, n *ast.TypeSpec) { + log := zerolog.Ctx(ctx) + log.Debug(). + Str("node-type", fmt.Sprintf("%T", n.Type)). + Msg("found node with acceptable type for mocking") + nv.declaredInterfaces = append(nv.declaredInterfaces, n.Name.Name) +} + func (nv *NodeVisitor) Visit(node ast.Node) ast.Visitor { + log := zerolog.Ctx(nv.ctx) + switch n := node.(type) { case *ast.TypeSpec: + log := log.With(). + Str("node-name", n.Name.Name). + Str("node-type", fmt.Sprintf("%T", n.Type)). + Logger() + switch n.Type.(type) { - case *ast.InterfaceType, *ast.FuncType: - nv.declaredInterfaces = append(nv.declaredInterfaces, n.Name.Name) + case *ast.FuncType: + if nv.disableFuncMocks { + break + } + nv.add(nv.ctx, n) + case *ast.InterfaceType, *ast.IndexExpr: + nv.add(nv.ctx, n) + default: + log.Debug().Msg("Found node with unacceptable type for mocking. Rejecting.") } } return nv diff --git a/vendor/github.com/vektra/mockery/v2/pkg/walker.go b/vendor/github.com/vektra/mockery/v2/pkg/walker.go index 34bab4e0e..bf051579d 100644 --- a/vendor/github.com/vektra/mockery/v2/pkg/walker.go +++ b/vendor/github.com/vektra/mockery/v2/pkg/walker.go @@ -38,7 +38,7 @@ func (w *Walker) Walk(ctx context.Context, visitor WalkerVisitor) (generated boo parser := NewParser(w.BuildTags) w.doWalk(ctx, parser, w.BaseDir) - err := parser.Load() + err := parser.Load(ctx) if err != nil { fmt.Fprintf(os.Stderr, "Error walking: %v\n", err) os.Exit(1) |
