upgrade to latest dependencies (#1881)

bumping knative.dev/eventing da0fba3...4d14c21:
  > 4d14c21 Added test for multiple sinks, multiple triggers (# 7350)
  > a261e06 OIDC - Support auto generation of PingSource identity service account and expose in AuthStatus (# 7344)
  > 16d75a9 mt-broker-ingress check audience of received token (# 7336)
  > 3ef831c Increase expiration buffer time of OIDCTokenProviders cache to 5 minutes (# 7355)
  > 5168dc3 Update dependencies (# 7378)
  > f9314d8 [main] Upgrade to latest dependencies (# 7372)
  > 4a07fdc Move OIDC e2e tests to test/auth (# 7363)
  > 0933c11 Expose audience of an InMemoryChannel in its status (# 7371)
  > 169542f OIDC - Support auto generation of ApiServerSource identity service account and expose in AuthStatus (# 7330)
  > 62ec33b Support auto generation of Subscriptions identity service account and… (# 7338)
  > 0af3ef6 [main] Upgrade to latest dependencies (# 7370)
  > cf6b140 [main] Update community files (# 7369)
  > de6915a Pass sink namespace to PingSource (# 7368)
  > 6dca8c4 [main] Upgrade to latest dependencies (# 7366)
  > 082d90a Remove unneeded configmapinformer in sinkbinding controller (# 7357)
  > f321ba5 Update dependencies (# 7347)
  > 4c9ad03 Mark new trigger filter tests as beta (# 7349)
  > 494ebb2 bumped x/net to v0.17 to fix cve-2023-44487 (# 7348)
bumping knative.dev/networking 6c502de...2a7676e:
  > 2a7676e upgrade to latest dependencies (# 883)
  > b6cd712 upgrade to latest dependencies (# 882)
  > 64434a8 upgrade to latest dependencies (# 881)
  > fa72cb5 Update community files (# 880)
  > c086340 upgrade to latest dependencies (# 877)
bumping golang.org/x/mod baa5c2d...5b69280:
  > 5b69280 modfile: use new go version string format in error message
  > 273ef6c go.mod: update to go 1.18 and x/tools v0.13.0
bumping google.golang.org/genproto/googleapis/api 007df8e...d307bd8:
  > d307bd8 chore(all): auto-regenerate .pb.go files (# 1057)
  > 0333e04 chore(all): update all to e6e6cda (# 1055)
  > 427d036 chore: unfreeze grpc and fix build errors (# 1056)
  > e6e6cda chore(all): update all (# 1044)
  > c177e32 chore(deps): temporarily ignore grpc dep (# 1054)
bumping knative.dev/serving 6703812...425abcb:
  > 425abcb Update net-gateway-api nightly (# 14531)
  > 52a25fa Add security policy reference in serving (# 14544)
  > 9896079 Fix sec context and resources for performance jobs (# 14529)
  > 707d286 Test istio with system-internal-tls enabled (# 14494)
  > 1940e5a Update net-contour nightly (# 14533)
  > 264588a Update net-istio nightly (# 14535)
  > 840d7ee Update net-kourier nightly (# 14532)
  > a81290a Update net-certmanager nightly (# 14534)
  > 39ee6f7 Trust DataPlaneUserSAN from Activator to Queue-Proxy (# 14452)
  > 71085f8 Shell executor logs through testing.T in upgrade tests (# 14495)
  > 121e9db upgrade to latest dependencies (# 14526)
  > 4d36a14 Update community files (# 14525)
  > fff40ef Bound buffer for reading stats (# 14523)
  > eda7591 Update net-istio nightly (# 14524)
  > cbeb443 Update net-contour nightly (# 14490)
  > eac93b0 Update net-istio nightly (# 14518)
  > 6a21d8a don't run encryption tests with contour (# 14521)
  > 633e281 upgrade to latest dependencies (# 14515)
  > 42cf24f Update net-gateway-api nightly (# 14520)
  > 805bb38 Update net-certmanager nightly (# 14519)
  > b202e49 Update net-kourier nightly (# 14504)
bumping knative.dev/pkg 948f5f5...d6ab729:
  > d6ab729 upgrade to latest dependencies (# 2870)
  > 283df0b Don't migrate storage version if CRD has one storage version (# 2861)
  > d0c133d Revert "Fix potential redefined error with kubeconfig flag (# 2855)" (# 2869)
  > 44a8a5e Use `DialTLSContextFunc` instead of `tls.Config` for `NewProxyAutoTLSTransport` (# 2842)
  > 0d0cd4e Print each line separately in shell executor (# 2867)
  > 058f699 Update community files (# 2868)
  > cf06733 Bump google.golang.org/grpc from 1.58.2 to 1.58.3 (# 2866)
  > af47f2d Bump github.com/google/go-cmp from 0.5.9 to 0.6.0 (# 2865)
  > 16f23bd Bump google.golang.org/api from 0.145.0 to 0.147.0 (# 2864)
  > 3262b2b Bump golang.org/x/tools from 0.13.0 to 0.14.0 (# 2863)
  > 9051a45 Migrate knative.dev/hack/shell to knative.dev/pkg/test/shell (# 2856)
bumping github.com/google/go-cmp a97318b...c3ad843:
  > c3ad843 Add cmpopts.EquateComparable (# 340)
  > e250a55 Use of hotlinking of Go identifiers (# 337)
  > 8a3e8dd set workflow permission to read-only (# 327)
  > 8cea5de Pin GitHub action versions (# 332)
  > 3bb304a Run tests for Go 1.20 version (# 322)
  > 571a56b Remove purego fallbacks (# 325)
bumping knative.dev/client-pkg 9ed2a96...9cea6f6:
  > 9cea6f6 upgrade to latest dependencies (# 126)
  > b78888b upgrade to latest dependencies (# 115)
  > 1b87ecd Remove deprecated Serving API v1alpha1 (# 125)
  > 12d1700 Update community files (# 124)
bumping google.golang.org/grpc c0aa20a...bf05b95:
  > bf05b95 Change version.go to v1.58.3 (# 6707)
  > c40c9ba server: prohibit more than MaxConcurrentStreams handlers from running at once (# 6703) (# 6705)
  > dd9270d update version to 1.58.3-dev (# 6656)
bumping golang.org/x/tools b5e55d1...3f4194e:
  > 3f4194e go.mod: update golang.org/x dependencies
  > 1e4ce7c internal/refactor/inline: yet more tweaks to everything test
  > ee20ddf internal/refactor/inline: permit return conversions in tailcall
  > db1d1e0 gopls/internal/lsp: go to definition from embed directive
  > 2be977e internal/refactor/inline: work around channel type misformatting
  > 0ba9c84 internal/fuzzy: several improvements for symbol matching
  > c2725ad gopls: update x/telemetry dependency
  > e8722c0 go/types/internal/play: show types.Selection information
  > a819c61 internal/refactor/inline: eliminate unnecessary binding decl
  > 102b64b internal/refactor/inline: tweak everything-test docs again
  > 197e2c4 internal/refactor/inline: fix broken tests
  > 586b21a internal/refactor/inline: elide redundant braces
  > ca34416 internal/refactor/inline: fallible constant analysis
  > 6a38a5f internal/refactor/inline: use default working directory
  > c6d331d internal/refactor/inline: don't add same import PkgName twice
  > 1058109 internal/refactor/inline: don't insert unnecessary parens
  > d8e94f2 internal/refactor/inline: fix bug in shadow detection
  > 0adbf9c gopls/internal/lsp: simplify the telemetry prompt
  > 2ed4298 go/analysis/analysistest: format golden files before comparing
  > 451716b internal/refactor/inline: consider "", 0.0, 1.0 duplicable
  > 792f91f internal/refactor/inline: tweak everything test for cgo
  > 9416299 internal/refactor/inline: fix pkgname shadowing bug
  > 4cd12d6 gopls/internal/lsp/fake: don't set a completion budget for tests
  > 57ecf48 gopls/internal/lsp: hover over embed directives
  > 6de3448 gopls/internal/lsp/cache: remove snapshot.typeCheckMu
  > 7f23bc8 gopls/internal/regtest/source/completion: reuse functionCallSnippet in
  > 3d03fbd gopls/internal/lsp: use matcher score in ranking unimported candidates
  > 7577387 gopls/internal/lsp/source: don't complete to golang.org/toolchain
  > 4b34fbf internal/refactor/inline: fix bug discard receiver and spread
  > 6ec9b0f internal/refactor/inline: refine "last ref to caller local"
  > 08bdfec internal/refactor/inline: split up the big table
  > 486787e gopls/internal/lsp/source: Add ui.complete.completeFunctionCalls toggle
  > 9d2d0e8 gopls: set a context deadline after minimal completion results
  > 169105a internal/refactor/inline: insert conversions during substitution
  > b3ada30 internal/refactor/inline: analyze callee effects
  > 1602103 internal/refactor/inline: skip cgo tests on non-cgo builders
  > 1c8e684 internal/refactor/inline: sound treatment of named results
  > d32f97a internal/refactor/inline: eliminate Callee.BodyIsReturnExpr
  > f4abeae go/analysis/passes/directive: use strings.Cut
  > c42ed47 internal/refactor/inline: reject attempts to inline in cgo code
  > 313150a internal/refactor/inline: x++ counts as assignment in escape
  > d6f1bb7 internal/refactor/inline: ignore line directives in testing
  > fb7463a gopls: upgrade x/telemetry to latest
  > 6ccb09c gopls/internal/lsp/source/completion: fixes for completion budget
  > 903e689 gopls/internal/lsp/source/completion: start timing before type checking
  > 455b761 gopls/internal/lsp: use linkifyShowMessage in telemetryOnMessage
  > ebe11df gopls/internal/regtest/bench: add additional completion benchmarks
  > 0ceab5c internal/refactor/inline: split up the main function
  > f975935 gopls/internal/lsp: update telemetry prompt and add a follow-up message
  > 64beb95 gopls/internal/lsp/command: add maybePromptForTelemetry
  > 1c59c38 gopls/internal/lsp/source: add linkifyShowMessage (internal option)
  > d5538db gopls/internal/lsp/cmd: undocument gopls vulncheck
  > e3bbe43 gopls/internal/lsp: update prompting logic for local/off mode
  > 771061d gopls: instrument telemetry for latency of important operations
  > a490c54 all: register the appends analyzer in a few places and update gopls/go.mod
  > f096129 internal/refactor/inline: use escape analysis in purity
  > f9b8da7 go/analysis/passes/appends: rename package to appends
  > d744296 cmd/compilebench: check asm support for -compiling-runtime
  > f8acb7f gopls: update golang.org/x/telemetry dependency
  > 6120b45 go/packages: fix a typo of TypesInfo
  > 0669fa3 cmd/compilebench: fix assembler invocation
  > 9125a0f gopls/internal/lsp: minor cleanup to prompt logic
  > a3c6fd8 gopls/internal/lsp: add an idle prompt asking users to enable telemetry
  > c00d71d go/analysis: add a new analyzer for check missing values after append
  > 9df3852 internal/refactor/inline: two minor cleanups
  > b37e7e3 internal/refactor/inline: test everything
  > 6128895 gopls/internal/vulncheck/scan: buffer govulncheck STDERR output
  > d2b79cd gopls/internal/regtest/marker: rename to clarify marker types
  > 91fde38 gopls/internal/lsp/tests: eliminate several old marker types
  > a9b2439 go/packages: remove use of ioutil in test
  > 6d90c13 internal/refactor/inline: ignore line directives
  > 28990ac internal/refactor/inline: fix bug in /internal/ check for std
  > 365db56 tools: clean up after removing all references to ioutil
  > 5538375 internal/refactor/inline: fix import shadowing bug
  > c1a2c23 internal/refactor/inline: handle implicit field selections
  > 673f263 internal/refactor/inline: update docs
  > c4f811e internal/refactor/inline: reject generic methods for now
  > 2c15796 internal/diff/lcs: increase search depth to 100
  > 38f5195 internal/refactor/inline: treat self-ref as free ref
  > 866a6b0 gopls: update x/telemetry to the latest
  > afa68c9 gopls/internal: move builtin completion test to a regtest
  > dca7c82 gopls/internal/regtest: support full features of old completion markers
  > e2393ab gopls/internal/lsp/source: inliner: don't spam log
  > 8421a35 gopls/lsp/command: add gopls.add_telemetry_counters
  > 940ffda internal/refactor/inline: introduce "binding decls"
  > eaf809a internal/refactor/inline: 2 fixes in AnalyzeCallee recursion
  > 715a452 internal/refactor/inline: doc: optimizing compiler analogy
  > 0bcc621 internal/refactor/inline: simplify ordinary variadics
  > efaab95 internal/refactor/inline: simplify f(slice...) calls
  > d98bc1a gopls: improve usage instructions for neovim
  > 559c430 tools: replace references to obsolete package ioutils
  > 0b3914d go/analysis/passes/defers: rename Analyzer.Name to "defers"
  > ad827af internal/refactor/inline: add table-driven test
  > 8d6ad46 gopls/internal/regtest: port the codelens marker tests
  > 995ecf7 gopls/internal/lsp/source: recover from inliner panics
  > cf5aad9 gopls: update to use the new golang.org/x/vuln API
  > 33355ea internal/refactor/inline: add parameterless tailcall strategy
  > ebc1c29 internal/refactor/inline: parameter elimination
  > e6d89b4 gopls/internal/lsp/regtest: parallelize marker tests
  > 7e848b2 gopls/internal/lsp/regtest: port the highlight marker
  > 9886d98 all: get tests passing with 1.18 and 1.19
  > 0049711 go/types/internal/play: show underlying and core types
  > 627959a cmd/stringer: log more information in tests
  > cd231d8 gopls/internal/lsp: track didChangeConfiguration diagnostics for tests
  > 0a9721c gopls/internal/lsp: move options into the snapshot
  > fb4bd11 gopls/internal/lsp/cache: move Option management to the Server
  > 882bb14 go/analysis/unitchecker: revert subtle change to vendoring
  > fbb8910 go/types/internal/play: show TypeAndValue.mode
  > d06e891 gopls/internal/regtest/marker: support folding ranges
  > b0cdf01 gopls/internal/lsp/tests: eliminate the go1.18 summary file
  > c6e4421 gopls/internal/lsp/tests: simplify options
  > ab96dab gopls/internal/lsp/cache: move working dir to workspaceInformation
  > 1889c0e gopls/internal/lsp/cache: simplify file change propagation
  > 01224cd gopls/internal/lsp/cache: only evaluate fileMap.dirs when necessary
  > 15a23a9 gopls/internal/lsp/cache: consolidate logic for updating maps in clone
  > 56a1866 gopls: update staticcheck (v0.4.5)
  > 36c4f98 gopls/internal/lsp/cache: simplify tracking of snapshot directories
  > fe324ac all: tidy with -compat=1.18
bumping google.golang.org/genproto/googleapis/rpc e6e6cda...8bfb1ae:
  > 8bfb1ae chore(all): update all (# 1059)
  > ceb4ed7 chore(all): auto-regenerate .pb.go files (# 1058)
  > d307bd8 chore(all): auto-regenerate .pb.go files (# 1057)
  > 0333e04 chore(all): update all to e6e6cda (# 1055)
  > 427d036 chore: unfreeze grpc and fix build errors (# 1056)
bumping knative.dev/hack fc76874...2c938d4:
  > 2c938d4 Update community files (# 337)
bumping google.golang.org/api 788dc60...60e8678:
  > 60e8678 chore(main): release 0.147.0 (# 2210)
  > 8fd2dc4 chore(deps): bump golang.org/x/net from 0.16.0 to 0.17.0 in /internal/kokoro/discogen (# 2213)
  > 6d015e0 chore(all): update module golang.org/x/net to v0.17.0 [SECURITY] (# 2214)
  > e2368f8 feat(all): auto-regenerate discovery clients (# 2215)
  > df0b730 feat(all): auto-regenerate discovery clients (# 2211)
  > b3a71bd chore(all): update all (# 2207)
  > f2c2d1b feat(all): auto-regenerate discovery clients (# 2209)
  > ed48023 chore(main): release 0.146.0 (# 2204)
  > 9a034cd feat(all): auto-regenerate discovery clients (# 2206)
  > 4aa710d feat(all): auto-regenerate discovery clients (# 2205)
  > 1e9a43c feat(all): auto-regenerate discovery clients (# 2203)
bumping google.golang.org/genproto 007df8e...d307bd8:
  > d307bd8 chore(all): auto-regenerate .pb.go files (# 1057)
  > 0333e04 chore(all): update all to e6e6cda (# 1055)
  > 427d036 chore: unfreeze grpc and fix build errors (# 1056)
  > e6e6cda chore(all): update all (# 1044)
  > c177e32 chore(deps): temporarily ignore grpc dep (# 1054)

Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
Knative Automation 2023-10-20 11:12:00 -04:00 committed by GitHub
parent b658574638
commit f5ca3c78cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 346 additions and 282 deletions

28
go.mod
View File

@ -3,7 +3,7 @@ module knative.dev/client
go 1.18
require (
github.com/google/go-cmp v0.5.9
github.com/google/go-cmp v0.6.0
github.com/hashicorp/golang-lru v1.0.2
github.com/hashicorp/hcl v1.0.0
github.com/mitchellh/go-homedir v1.1.0
@ -11,7 +11,7 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.16.0
golang.org/x/mod v0.12.0
golang.org/x/mod v0.13.0
golang.org/x/term v0.13.0
gotest.tools/v3 v3.3.0
k8s.io/api v0.27.6
@ -20,12 +20,12 @@ require (
k8s.io/cli-runtime v0.26.5
k8s.io/client-go v0.27.6
k8s.io/code-generator v0.27.6
knative.dev/client-pkg v0.0.0-20231010132217-9ed2a9604c41
knative.dev/eventing v0.38.1-0.20231011142145-da0fba3c161a
knative.dev/hack v0.0.0-20231010131532-fc76874b28c6
knative.dev/networking v0.0.0-20231011064411-6c502de01ce6
knative.dev/pkg v0.0.0-20231011202506-948f5f57818a
knative.dev/serving v0.38.1-0.20231011210335-6703812f1314
knative.dev/client-pkg v0.0.0-20231020123408-9cea6f6e36ce
knative.dev/eventing v0.38.1-0.20231019170735-4d14c2126a20
knative.dev/hack v0.0.0-20231016131700-2c938d4918da
knative.dev/networking v0.0.0-20231017124814-2a7676e912b7
knative.dev/pkg v0.0.0-20231017113806-d6ab72900ea5
knative.dev/serving v0.38.1-0.20231020131030-425abcb95f5a
sigs.k8s.io/yaml v1.3.0
)
@ -109,14 +109,14 @@ require (
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/api v0.145.0 // indirect
google.golang.org/api v0.147.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect
google.golang.org/grpc v1.58.2 // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect

56
go.sum
View File

@ -185,8 +185,8 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
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.13.0 h1:y1C7Z3e149OJbOPDBxLYR8ITPz8dTKqQwjErKVHJC8k=
github.com/google/go-containerregistry v0.13.0/go.mod h1:J9FQ+eSS4a1aC2GNZxvNpbWhgp0487v+cgiilB4FqDo=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@ -462,8 +462,8 @@ 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.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.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-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -656,8 +656,8 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
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=
@ -684,8 +684,8 @@ google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz513
google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
google.golang.org/api v0.145.0 h1:kBjvf1A3/m30kUvnUX9jZJxTu3lJrpGFt5V/1YZrjwg=
google.golang.org/api v0.145.0/go.mod h1:OARJqIfoYjXJj4C1AiBSXYZt03qsoz8FQYU6fBEfrHM=
google.golang.org/api v0.147.0 h1:Can3FaQo9LlVqxJCodNmeZW/ib3/qKAY3rFeXiHo5gc=
google.golang.org/api v0.147.0/go.mod h1:pQ/9j83DcmPd/5C9e2nFOdjjNkDZ1G+zkbK2uvdkJMs=
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/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@ -733,12 +733,12 @@ google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb h1:XFBgcDwm7irdHTbz4Zk2h7Mh+eis4nfJEFQFYzJzuIA=
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4=
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI=
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA=
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0=
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk=
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU=
google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
@ -758,8 +758,8 @@ google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA5
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I=
google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
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=
@ -832,18 +832,18 @@ k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5F
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg=
k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY=
k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/client-pkg v0.0.0-20231010132217-9ed2a9604c41 h1:KHyc56BB9dCQAXHX/4/tVY34bdLhBDeNH4SqKrPdONg=
knative.dev/client-pkg v0.0.0-20231010132217-9ed2a9604c41/go.mod h1:GRVZm1rKOy0lpPBGRM1ugK5joDbhXFEvULINHqPoA9U=
knative.dev/eventing v0.38.1-0.20231011142145-da0fba3c161a h1:PGQLztMZU+LvYoJxD1opXH3wbVsVcza9CXSrE3UFFCA=
knative.dev/eventing v0.38.1-0.20231011142145-da0fba3c161a/go.mod h1:j7WTKE45cYdLqOPbezFVUxOwNKoVU4pA5uMqzuQ78zo=
knative.dev/hack v0.0.0-20231010131532-fc76874b28c6 h1:K9saPnpWTK1xH/Dpx1aE4CA+4GR7AXSxQthwLXEf+zM=
knative.dev/hack v0.0.0-20231010131532-fc76874b28c6/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/networking v0.0.0-20231011064411-6c502de01ce6 h1:1HnggeWAU1Td32xgmcx0vKuHnMwYKPoyV4N7OjQvobI=
knative.dev/networking v0.0.0-20231011064411-6c502de01ce6/go.mod h1:Sgm4C/gsmsMNIiEa+fVmAi54nICdR/ko8equA/rgKMc=
knative.dev/pkg v0.0.0-20231011202506-948f5f57818a h1:/Ia2DN9jWwz0CSLXFq0iwvMK4Tx4Iy9WoMvoPn1ri98=
knative.dev/pkg v0.0.0-20231011202506-948f5f57818a/go.mod h1:0HqD8pZppFF34znDJnN6fGzuFq9ulJnelX64ciHD+PE=
knative.dev/serving v0.38.1-0.20231011210335-6703812f1314 h1:w1F7bA1+DEJBxaJrOhmKCasqYJ/uEcVOJpmHHEGuiug=
knative.dev/serving v0.38.1-0.20231011210335-6703812f1314/go.mod h1:wnuCaMuLfBdOHgs1OfYPvEFN4xqH3GL6aTBv+xqdgKQ=
knative.dev/client-pkg v0.0.0-20231020123408-9cea6f6e36ce h1:fz2hdUHqSbWpspy1amShnY+7/4ijHQ9crf8TgTwSmX0=
knative.dev/client-pkg v0.0.0-20231020123408-9cea6f6e36ce/go.mod h1:y7QlbxfJzCvepGOCrM4vGco9UP9DaWXqRviXxH3yltM=
knative.dev/eventing v0.38.1-0.20231019170735-4d14c2126a20 h1:j6jW2x0lWlEvQ84mal81dvA6skA085LSFTGfLEdo9U8=
knative.dev/eventing v0.38.1-0.20231019170735-4d14c2126a20/go.mod h1:swWS48qpCQbBkj+2iS0rVa7PbQBWLD9YAy3CSHfevaU=
knative.dev/hack v0.0.0-20231016131700-2c938d4918da h1:xy+fvuz2LDOMsZ5UwXRaMF70NYUs9fsG+EF5/ierYBg=
knative.dev/hack v0.0.0-20231016131700-2c938d4918da/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/networking v0.0.0-20231017124814-2a7676e912b7 h1:6+1icZuxiZO1paFZ4d/ysKWVG2M4WB7OxNJNyLG0P/E=
knative.dev/networking v0.0.0-20231017124814-2a7676e912b7/go.mod h1:1gcHoIVG47ekQWjkddqRq+/7tWRh+CB9W4k/NAcdRbk=
knative.dev/pkg v0.0.0-20231017113806-d6ab72900ea5 h1:9AvFZdEtuwKWDcTV1VSwmrgrRR9f38wbIAm+sNwLivQ=
knative.dev/pkg v0.0.0-20231017113806-d6ab72900ea5/go.mod h1:HHRXEd7ZlFpthgE+rwAZ6MUVnuJOAeolnaFSthXloUQ=
knative.dev/serving v0.38.1-0.20231020131030-425abcb95f5a h1:4TQvxDYKxdYOXHCjqx4A8iL/Z+eBAXbGcfrh4ANdwQY=
knative.dev/serving v0.38.1-0.20231020131030-425abcb95f5a/go.mod h1:cuia3pUQNF4sa3g3KsPFgqpLnF1pf9iquDLgk71iLfo=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

View File

@ -7,6 +7,7 @@ package cmpopts
import (
"errors"
"fmt"
"math"
"reflect"
"time"
@ -16,10 +17,10 @@ import (
func equateAlways(_, _ interface{}) bool { return true }
// EquateEmpty returns a Comparer option that determines all maps and slices
// EquateEmpty returns a [cmp.Comparer] option that determines all maps and slices
// with a length of zero to be equal, regardless of whether they are nil.
//
// EquateEmpty can be used in conjunction with SortSlices and SortMaps.
// EquateEmpty can be used in conjunction with [SortSlices] and [SortMaps].
func EquateEmpty() cmp.Option {
return cmp.FilterValues(isEmpty, cmp.Comparer(equateAlways))
}
@ -31,7 +32,7 @@ func isEmpty(x, y interface{}) bool {
(vx.Len() == 0 && vy.Len() == 0)
}
// EquateApprox returns a Comparer option that determines float32 or float64
// EquateApprox returns a [cmp.Comparer] option that determines float32 or float64
// values to be equal if they are within a relative fraction or absolute margin.
// This option is not used when either x or y is NaN or infinite.
//
@ -45,7 +46,7 @@ func isEmpty(x, y interface{}) bool {
//
// |x-y| ≤ max(fraction*min(|x|, |y|), margin)
//
// EquateApprox can be used in conjunction with EquateNaNs.
// EquateApprox can be used in conjunction with [EquateNaNs].
func EquateApprox(fraction, margin float64) cmp.Option {
if margin < 0 || fraction < 0 || math.IsNaN(margin) || math.IsNaN(fraction) {
panic("margin or fraction must be a non-negative number")
@ -73,10 +74,10 @@ func (a approximator) compareF32(x, y float32) bool {
return a.compareF64(float64(x), float64(y))
}
// EquateNaNs returns a Comparer option that determines float32 and float64
// EquateNaNs returns a [cmp.Comparer] option that determines float32 and float64
// NaN values to be equal.
//
// EquateNaNs can be used in conjunction with EquateApprox.
// EquateNaNs can be used in conjunction with [EquateApprox].
func EquateNaNs() cmp.Option {
return cmp.Options{
cmp.FilterValues(areNaNsF64s, cmp.Comparer(equateAlways)),
@ -91,8 +92,8 @@ func areNaNsF32s(x, y float32) bool {
return areNaNsF64s(float64(x), float64(y))
}
// EquateApproxTime returns a Comparer option that determines two non-zero
// time.Time values to be equal if they are within some margin of one another.
// EquateApproxTime returns a [cmp.Comparer] option that determines two non-zero
// [time.Time] values to be equal if they are within some margin of one another.
// If both times have a monotonic clock reading, then the monotonic time
// difference will be used. The margin must be non-negative.
func EquateApproxTime(margin time.Duration) cmp.Option {
@ -131,8 +132,8 @@ type anyError struct{}
func (anyError) Error() string { return "any error" }
func (anyError) Is(err error) bool { return err != nil }
// EquateErrors returns a Comparer option that determines errors to be equal
// if errors.Is reports them to match. The AnyError error can be used to
// EquateErrors returns a [cmp.Comparer] option that determines errors to be equal
// if [errors.Is] reports them to match. The [AnyError] error can be used to
// match any non-nil error.
func EquateErrors() cmp.Option {
return cmp.FilterValues(areConcreteErrors, cmp.Comparer(compareErrors))
@ -154,3 +155,31 @@ func compareErrors(x, y interface{}) bool {
ye := y.(error)
return errors.Is(xe, ye) || errors.Is(ye, xe)
}
// EquateComparable returns a [cmp.Option] that determines equality
// of comparable types by directly comparing them using the == operator in Go.
// The types to compare are specified by passing a value of that type.
// This option should only be used on types that are documented as being
// safe for direct == comparison. For example, [net/netip.Addr] is documented
// as being semantically safe to use with ==, while [time.Time] is documented
// to discourage the use of == on time values.
func EquateComparable(typs ...interface{}) cmp.Option {
types := make(typesFilter)
for _, typ := range typs {
switch t := reflect.TypeOf(typ); {
case !t.Comparable():
panic(fmt.Sprintf("%T is not a comparable Go type", typ))
case types[t]:
panic(fmt.Sprintf("%T is already specified", typ))
default:
types[t] = true
}
}
return cmp.FilterPath(types.filter, cmp.Comparer(equateAny))
}
type typesFilter map[reflect.Type]bool
func (tf typesFilter) filter(p cmp.Path) bool { return tf[p.Last().Type()] }
func equateAny(x, y interface{}) bool { return x == y }

View File

@ -14,7 +14,7 @@ import (
"github.com/google/go-cmp/cmp/internal/function"
)
// IgnoreFields returns an Option that ignores fields of the
// IgnoreFields returns an [cmp.Option] that ignores fields of the
// given names on a single struct type. It respects the names of exported fields
// that are forwarded due to struct embedding.
// The struct type is specified by passing in a value of that type.
@ -26,7 +26,7 @@ func IgnoreFields(typ interface{}, names ...string) cmp.Option {
return cmp.FilterPath(sf.filter, cmp.Ignore())
}
// IgnoreTypes returns an Option that ignores all values assignable to
// IgnoreTypes returns an [cmp.Option] that ignores all values assignable to
// certain types, which are specified by passing in a value of each type.
func IgnoreTypes(typs ...interface{}) cmp.Option {
tf := newTypeFilter(typs...)
@ -59,10 +59,10 @@ func (tf typeFilter) filter(p cmp.Path) bool {
return false
}
// IgnoreInterfaces returns an Option that ignores all values or references of
// IgnoreInterfaces returns an [cmp.Option] that ignores all values or references of
// values assignable to certain interface types. These interfaces are specified
// by passing in an anonymous struct with the interface types embedded in it.
// For example, to ignore sync.Locker, pass in struct{sync.Locker}{}.
// For example, to ignore [sync.Locker], pass in struct{sync.Locker}{}.
func IgnoreInterfaces(ifaces interface{}) cmp.Option {
tf := newIfaceFilter(ifaces)
return cmp.FilterPath(tf.filter, cmp.Ignore())
@ -107,7 +107,7 @@ func (tf ifaceFilter) filter(p cmp.Path) bool {
return false
}
// IgnoreUnexported returns an Option that only ignores the immediate unexported
// IgnoreUnexported returns an [cmp.Option] that only ignores the immediate unexported
// fields of a struct, including anonymous fields of unexported types.
// In particular, unexported fields within the struct's exported fields
// of struct types, including anonymous fields, will not be ignored unless the
@ -115,7 +115,7 @@ func (tf ifaceFilter) filter(p cmp.Path) bool {
//
// Avoid ignoring unexported fields of a type which you do not control (i.e. a
// type from another repository), as changes to the implementation of such types
// may change how the comparison behaves. Prefer a custom Comparer instead.
// may change how the comparison behaves. Prefer a custom [cmp.Comparer] instead.
func IgnoreUnexported(typs ...interface{}) cmp.Option {
ux := newUnexportedFilter(typs...)
return cmp.FilterPath(ux.filter, cmp.Ignore())
@ -148,7 +148,7 @@ func isExported(id string) bool {
return unicode.IsUpper(r)
}
// IgnoreSliceElements returns an Option that ignores elements of []V.
// IgnoreSliceElements returns an [cmp.Option] that ignores elements of []V.
// The discard function must be of the form "func(T) bool" which is used to
// ignore slice elements of type V, where V is assignable to T.
// Elements are ignored if the function reports true.
@ -176,7 +176,7 @@ func IgnoreSliceElements(discardFunc interface{}) cmp.Option {
}, cmp.Ignore())
}
// IgnoreMapEntries returns an Option that ignores entries of map[K]V.
// IgnoreMapEntries returns an [cmp.Option] that ignores entries of map[K]V.
// The discard function must be of the form "func(T, R) bool" which is used to
// ignore map entries of type K and V, where K and V are assignable to T and R.
// Entries are ignored if the function reports true.

View File

@ -13,7 +13,7 @@ import (
"github.com/google/go-cmp/cmp/internal/function"
)
// SortSlices returns a Transformer option that sorts all []V.
// SortSlices returns a [cmp.Transformer] option that sorts all []V.
// The less function must be of the form "func(T, T) bool" which is used to
// sort any slice with element type V that is assignable to T.
//
@ -25,7 +25,7 @@ import (
// The less function does not have to be "total". That is, if !less(x, y) and
// !less(y, x) for two elements x and y, their relative order is maintained.
//
// SortSlices can be used in conjunction with EquateEmpty.
// SortSlices can be used in conjunction with [EquateEmpty].
func SortSlices(lessFunc interface{}) cmp.Option {
vf := reflect.ValueOf(lessFunc)
if !function.IsType(vf.Type(), function.Less) || vf.IsNil() {
@ -82,13 +82,13 @@ func (ss sliceSorter) less(v reflect.Value, i, j int) bool {
return ss.fnc.Call([]reflect.Value{vx, vy})[0].Bool()
}
// SortMaps returns a Transformer option that flattens map[K]V types to be a
// SortMaps returns a [cmp.Transformer] option that flattens map[K]V types to be a
// sorted []struct{K, V}. The less function must be of the form
// "func(T, T) bool" which is used to sort any map with key K that is
// assignable to T.
//
// Flattening the map into a slice has the property that cmp.Equal is able to
// use Comparers on K or the K.Equal method if it exists.
// Flattening the map into a slice has the property that [cmp.Equal] is able to
// use [cmp.Comparer] options on K or the K.Equal method if it exists.
//
// The less function must be:
// - Deterministic: less(x, y) == less(x, y)
@ -96,7 +96,7 @@ func (ss sliceSorter) less(v reflect.Value, i, j int) bool {
// - Transitive: if !less(x, y) and !less(y, z), then !less(x, z)
// - Total: if x != y, then either less(x, y) or less(y, x)
//
// SortMaps can be used in conjunction with EquateEmpty.
// SortMaps can be used in conjunction with [EquateEmpty].
func SortMaps(lessFunc interface{}) cmp.Option {
vf := reflect.ValueOf(lessFunc)
if !function.IsType(vf.Type(), function.Less) || vf.IsNil() {

View File

@ -19,7 +19,7 @@ func (xf xformFilter) filter(p cmp.Path) bool {
return true
}
// AcyclicTransformer returns a Transformer with a filter applied that ensures
// AcyclicTransformer returns a [cmp.Transformer] with a filter applied that ensures
// that the transformer cannot be recursively applied upon its own output.
//
// An example use case is a transformer that splits a string by lines:
@ -28,7 +28,7 @@ func (xf xformFilter) filter(p cmp.Path) bool {
// return strings.Split(s, "\n")
// })
//
// Had this been an unfiltered Transformer instead, this would result in an
// Had this been an unfiltered [cmp.Transformer] instead, this would result in an
// infinite cycle converting a string to []string to [][]string and so on.
func AcyclicTransformer(name string, xformFunc interface{}) cmp.Option {
xf := xformFilter{cmp.Transformer(name, xformFunc)}

View File

@ -5,7 +5,7 @@
// Package cmp determines equality of values.
//
// This package is intended to be a more powerful and safer alternative to
// reflect.DeepEqual for comparing whether two values are semantically equal.
// [reflect.DeepEqual] for comparing whether two values are semantically equal.
// It is intended to only be used in tests, as performance is not a goal and
// it may panic if it cannot compare the values. Its propensity towards
// panicking means that its unsuitable for production environments where a
@ -18,16 +18,17 @@
// For example, an equality function may report floats as equal so long as
// they are within some tolerance of each other.
//
// - Types with an Equal method may use that method to determine equality.
// This allows package authors to determine the equality operation
// for the types that they define.
// - Types with an Equal method (e.g., [time.Time.Equal]) may use that method
// to determine equality. This allows package authors to determine
// the equality operation for the types that they define.
//
// - If no custom equality functions are used and no Equal method is defined,
// equality is determined by recursively comparing the primitive kinds on
// both values, much like reflect.DeepEqual. Unlike reflect.DeepEqual,
// both values, much like [reflect.DeepEqual]. Unlike [reflect.DeepEqual],
// unexported fields are not compared by default; they result in panics
// unless suppressed by using an Ignore option (see cmpopts.IgnoreUnexported)
// or explicitly compared using the Exporter option.
// unless suppressed by using an [Ignore] option
// (see [github.com/google/go-cmp/cmp/cmpopts.IgnoreUnexported])
// or explicitly compared using the [Exporter] option.
package cmp
import (
@ -45,14 +46,14 @@ import (
// Equal reports whether x and y are equal by recursively applying the
// following rules in the given order to x and y and all of their sub-values:
//
// - Let S be the set of all Ignore, Transformer, and Comparer options that
// - Let S be the set of all [Ignore], [Transformer], and [Comparer] options that
// remain after applying all path filters, value filters, and type filters.
// If at least one Ignore exists in S, then the comparison is ignored.
// If the number of Transformer and Comparer options in S is non-zero,
// If at least one [Ignore] exists in S, then the comparison is ignored.
// If the number of [Transformer] and [Comparer] options in S is non-zero,
// then Equal panics because it is ambiguous which option to use.
// If S contains a single Transformer, then use that to transform
// If S contains a single [Transformer], then use that to transform
// the current values and recursively call Equal on the output values.
// If S contains a single Comparer, then use that to compare the current values.
// If S contains a single [Comparer], then use that to compare the current values.
// Otherwise, evaluation proceeds to the next rule.
//
// - If the values have an Equal method of the form "(T) Equal(T) bool" or
@ -66,21 +67,22 @@ import (
// Functions are only equal if they are both nil, otherwise they are unequal.
//
// Structs are equal if recursively calling Equal on all fields report equal.
// If a struct contains unexported fields, Equal panics unless an Ignore option
// (e.g., cmpopts.IgnoreUnexported) ignores that field or the Exporter option
// explicitly permits comparing the unexported field.
// If a struct contains unexported fields, Equal panics unless an [Ignore] option
// (e.g., [github.com/google/go-cmp/cmp/cmpopts.IgnoreUnexported]) ignores that field
// or the [Exporter] option explicitly permits comparing the unexported field.
//
// Slices are equal if they are both nil or both non-nil, where recursively
// calling Equal on all non-ignored slice or array elements report equal.
// Empty non-nil slices and nil slices are not equal; to equate empty slices,
// consider using cmpopts.EquateEmpty.
// consider using [github.com/google/go-cmp/cmp/cmpopts.EquateEmpty].
//
// Maps are equal if they are both nil or both non-nil, where recursively
// calling Equal on all non-ignored map entries report equal.
// Map keys are equal according to the == operator.
// To use custom comparisons for map keys, consider using cmpopts.SortMaps.
// To use custom comparisons for map keys, consider using
// [github.com/google/go-cmp/cmp/cmpopts.SortMaps].
// Empty non-nil maps and nil maps are not equal; to equate empty maps,
// consider using cmpopts.EquateEmpty.
// consider using [github.com/google/go-cmp/cmp/cmpopts.EquateEmpty].
//
// Pointers and interfaces are equal if they are both nil or both non-nil,
// where they have the same underlying concrete type and recursively

View File

@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !purego
// +build !purego
package cmp
import (
@ -12,8 +9,6 @@ import (
"unsafe"
)
const supportExporters = true
// retrieveUnexportedField uses unsafe to forcibly retrieve any field from
// a struct such that the value has read-write permissions.
//

View File

@ -1,16 +0,0 @@
// Copyright 2017, The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build purego
// +build purego
package cmp
import "reflect"
const supportExporters = false
func retrieveUnexportedField(reflect.Value, reflect.StructField, bool) reflect.Value {
panic("no support for forcibly accessing unexported fields")
}

View File

@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !purego
// +build !purego
package value
import (

View File

@ -1,34 +0,0 @@
// Copyright 2018, The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build purego
// +build purego
package value
import "reflect"
// Pointer is an opaque typed pointer and is guaranteed to be comparable.
type Pointer struct {
p uintptr
t reflect.Type
}
// PointerOf returns a Pointer from v, which must be a
// reflect.Ptr, reflect.Slice, or reflect.Map.
func PointerOf(v reflect.Value) Pointer {
// NOTE: Storing a pointer as an uintptr is technically incorrect as it
// assumes that the GC implementation does not use a moving collector.
return Pointer{v.Pointer(), v.Type()}
}
// IsNil reports whether the pointer is nil.
func (p Pointer) IsNil() bool {
return p.p == 0
}
// Uintptr returns the pointer as a uintptr.
func (p Pointer) Uintptr() uintptr {
return p.p
}

View File

@ -13,15 +13,15 @@ import (
"github.com/google/go-cmp/cmp/internal/function"
)
// Option configures for specific behavior of Equal and Diff. In particular,
// the fundamental Option functions (Ignore, Transformer, and Comparer),
// Option configures for specific behavior of [Equal] and [Diff]. In particular,
// the fundamental Option functions ([Ignore], [Transformer], and [Comparer]),
// configure how equality is determined.
//
// The fundamental options may be composed with filters (FilterPath and
// FilterValues) to control the scope over which they are applied.
// The fundamental options may be composed with filters ([FilterPath] and
// [FilterValues]) to control the scope over which they are applied.
//
// The cmp/cmpopts package provides helper functions for creating options that
// may be used with Equal and Diff.
// The [github.com/google/go-cmp/cmp/cmpopts] package provides helper functions
// for creating options that may be used with [Equal] and [Diff].
type Option interface {
// filter applies all filters and returns the option that remains.
// Each option may only read s.curPath and call s.callTTBFunc.
@ -56,9 +56,9 @@ type core struct{}
func (core) isCore() {}
// Options is a list of Option values that also satisfies the Option interface.
// Options is a list of [Option] values that also satisfies the [Option] interface.
// Helper comparison packages may return an Options value when packing multiple
// Option values into a single Option. When this package processes an Options,
// [Option] values into a single [Option]. When this package processes an Options,
// it will be implicitly expanded into a flat list.
//
// Applying a filter on an Options is equivalent to applying that same filter
@ -105,16 +105,16 @@ func (opts Options) String() string {
return fmt.Sprintf("Options{%s}", strings.Join(ss, ", "))
}
// FilterPath returns a new Option where opt is only evaluated if filter f
// returns true for the current Path in the value tree.
// FilterPath returns a new [Option] where opt is only evaluated if filter f
// returns true for the current [Path] in the value tree.
//
// This filter is called even if a slice element or map entry is missing and
// provides an opportunity to ignore such cases. The filter function must be
// symmetric such that the filter result is identical regardless of whether the
// missing value is from x or y.
//
// The option passed in may be an Ignore, Transformer, Comparer, Options, or
// a previously filtered Option.
// The option passed in may be an [Ignore], [Transformer], [Comparer], [Options], or
// a previously filtered [Option].
func FilterPath(f func(Path) bool, opt Option) Option {
if f == nil {
panic("invalid path filter function")
@ -142,7 +142,7 @@ func (f pathFilter) String() string {
return fmt.Sprintf("FilterPath(%s, %v)", function.NameOf(reflect.ValueOf(f.fnc)), f.opt)
}
// FilterValues returns a new Option where opt is only evaluated if filter f,
// FilterValues returns a new [Option] where opt is only evaluated if filter f,
// which is a function of the form "func(T, T) bool", returns true for the
// current pair of values being compared. If either value is invalid or
// the type of the values is not assignable to T, then this filter implicitly
@ -154,8 +154,8 @@ func (f pathFilter) String() string {
// If T is an interface, it is possible that f is called with two values with
// different concrete types that both implement T.
//
// The option passed in may be an Ignore, Transformer, Comparer, Options, or
// a previously filtered Option.
// The option passed in may be an [Ignore], [Transformer], [Comparer], [Options], or
// a previously filtered [Option].
func FilterValues(f interface{}, opt Option) Option {
v := reflect.ValueOf(f)
if !function.IsType(v.Type(), function.ValueFilter) || v.IsNil() {
@ -192,9 +192,9 @@ func (f valuesFilter) String() string {
return fmt.Sprintf("FilterValues(%s, %v)", function.NameOf(f.fnc), f.opt)
}
// Ignore is an Option that causes all comparisons to be ignored.
// This value is intended to be combined with FilterPath or FilterValues.
// It is an error to pass an unfiltered Ignore option to Equal.
// Ignore is an [Option] that causes all comparisons to be ignored.
// This value is intended to be combined with [FilterPath] or [FilterValues].
// It is an error to pass an unfiltered Ignore option to [Equal].
func Ignore() Option { return ignore{} }
type ignore struct{ core }
@ -234,6 +234,8 @@ func (validator) apply(s *state, vx, vy reflect.Value) {
name = fmt.Sprintf("%q.%v", t.PkgPath(), t.Name()) // e.g., "path/to/package".MyType
if _, ok := reflect.New(t).Interface().(error); ok {
help = "consider using cmpopts.EquateErrors to compare error values"
} else if t.Comparable() {
help = "consider using cmpopts.EquateComparable to compare comparable Go types"
}
} else {
// Unnamed type with unexported fields. Derive PkgPath from field.
@ -254,7 +256,7 @@ const identRx = `[_\p{L}][_\p{L}\p{N}]*`
var identsRx = regexp.MustCompile(`^` + identRx + `(\.` + identRx + `)*$`)
// Transformer returns an Option that applies a transformation function that
// Transformer returns an [Option] that applies a transformation function that
// converts values of a certain type into that of another.
//
// The transformer f must be a function "func(T) R" that converts values of
@ -265,13 +267,14 @@ var identsRx = regexp.MustCompile(`^` + identRx + `(\.` + identRx + `)*$`)
// same transform to the output of itself (e.g., in the case where the
// input and output types are the same), an implicit filter is added such that
// a transformer is applicable only if that exact transformer is not already
// in the tail of the Path since the last non-Transform step.
// in the tail of the [Path] since the last non-[Transform] step.
// For situations where the implicit filter is still insufficient,
// consider using cmpopts.AcyclicTransformer, which adds a filter
// to prevent the transformer from being recursively applied upon itself.
// consider using [github.com/google/go-cmp/cmp/cmpopts.AcyclicTransformer],
// which adds a filter to prevent the transformer from
// being recursively applied upon itself.
//
// The name is a user provided label that is used as the Transform.Name in the
// transformation PathStep (and eventually shown in the Diff output).
// The name is a user provided label that is used as the [Transform.Name] in the
// transformation [PathStep] (and eventually shown in the [Diff] output).
// The name must be a valid identifier or qualified identifier in Go syntax.
// If empty, an arbitrary name is used.
func Transformer(name string, f interface{}) Option {
@ -329,7 +332,7 @@ func (tr transformer) String() string {
return fmt.Sprintf("Transformer(%s, %s)", tr.name, function.NameOf(tr.fnc))
}
// Comparer returns an Option that determines whether two values are equal
// Comparer returns an [Option] that determines whether two values are equal
// to each other.
//
// The comparer f must be a function "func(T, T) bool" and is implicitly
@ -377,35 +380,32 @@ func (cm comparer) String() string {
return fmt.Sprintf("Comparer(%s)", function.NameOf(cm.fnc))
}
// Exporter returns an Option that specifies whether Equal is allowed to
// Exporter returns an [Option] that specifies whether [Equal] is allowed to
// introspect into the unexported fields of certain struct types.
//
// Users of this option must understand that comparing on unexported fields
// from external packages is not safe since changes in the internal
// implementation of some external package may cause the result of Equal
// implementation of some external package may cause the result of [Equal]
// to unexpectedly change. However, it may be valid to use this option on types
// defined in an internal package where the semantic meaning of an unexported
// field is in the control of the user.
//
// In many cases, a custom Comparer should be used instead that defines
// In many cases, a custom [Comparer] should be used instead that defines
// equality as a function of the public API of a type rather than the underlying
// unexported implementation.
//
// For example, the reflect.Type documentation defines equality to be determined
// For example, the [reflect.Type] documentation defines equality to be determined
// by the == operator on the interface (essentially performing a shallow pointer
// comparison) and most attempts to compare *regexp.Regexp types are interested
// comparison) and most attempts to compare *[regexp.Regexp] types are interested
// in only checking that the regular expression strings are equal.
// Both of these are accomplished using Comparers:
// Both of these are accomplished using [Comparer] options:
//
// Comparer(func(x, y reflect.Type) bool { return x == y })
// Comparer(func(x, y *regexp.Regexp) bool { return x.String() == y.String() })
//
// In other cases, the cmpopts.IgnoreUnexported option can be used to ignore
// all unexported fields on specified struct types.
// In other cases, the [github.com/google/go-cmp/cmp/cmpopts.IgnoreUnexported]
// option can be used to ignore all unexported fields on specified struct types.
func Exporter(f func(reflect.Type) bool) Option {
if !supportExporters {
panic("Exporter is not supported on purego builds")
}
return exporter(f)
}
@ -415,10 +415,10 @@ func (exporter) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableO
panic("not implemented")
}
// AllowUnexported returns an Options that allows Equal to forcibly introspect
// AllowUnexported returns an [Option] that allows [Equal] to forcibly introspect
// unexported fields of the specified struct types.
//
// See Exporter for the proper use of this option.
// See [Exporter] for the proper use of this option.
func AllowUnexported(types ...interface{}) Option {
m := make(map[reflect.Type]bool)
for _, typ := range types {
@ -432,7 +432,7 @@ func AllowUnexported(types ...interface{}) Option {
}
// Result represents the comparison result for a single node and
// is provided by cmp when calling Report (see Reporter).
// is provided by cmp when calling Report (see [Reporter]).
type Result struct {
_ [0]func() // Make Result incomparable
flags resultFlags
@ -445,7 +445,7 @@ func (r Result) Equal() bool {
}
// ByIgnore reports whether the node is equal because it was ignored.
// This never reports true if Equal reports false.
// This never reports true if [Result.Equal] reports false.
func (r Result) ByIgnore() bool {
return r.flags&reportByIgnore != 0
}
@ -455,7 +455,7 @@ func (r Result) ByMethod() bool {
return r.flags&reportByMethod != 0
}
// ByFunc reports whether a Comparer function determined equality.
// ByFunc reports whether a [Comparer] function determined equality.
func (r Result) ByFunc() bool {
return r.flags&reportByFunc != 0
}
@ -478,7 +478,7 @@ const (
reportByCycle
)
// Reporter is an Option that can be passed to Equal. When Equal traverses
// Reporter is an [Option] that can be passed to [Equal]. When [Equal] traverses
// the value trees, it calls PushStep as it descends into each node in the
// tree and PopStep as it ascend out of the node. The leaves of the tree are
// either compared (determined to be equal or not equal) or ignored and reported

View File

@ -14,9 +14,9 @@ import (
"github.com/google/go-cmp/cmp/internal/value"
)
// Path is a list of PathSteps describing the sequence of operations to get
// Path is a list of [PathStep] describing the sequence of operations to get
// from some root type to the current position in the value tree.
// The first Path element is always an operation-less PathStep that exists
// The first Path element is always an operation-less [PathStep] that exists
// simply to identify the initial type.
//
// When traversing structs with embedded structs, the embedded struct will
@ -29,8 +29,13 @@ type Path []PathStep
// a value's tree structure. Users of this package never need to implement
// these types as values of this type will be returned by this package.
//
// Implementations of this interface are
// StructField, SliceIndex, MapIndex, Indirect, TypeAssertion, and Transform.
// Implementations of this interface:
// - [StructField]
// - [SliceIndex]
// - [MapIndex]
// - [Indirect]
// - [TypeAssertion]
// - [Transform]
type PathStep interface {
String() string
@ -70,8 +75,9 @@ func (pa *Path) pop() {
*pa = (*pa)[:len(*pa)-1]
}
// Last returns the last PathStep in the Path.
// If the path is empty, this returns a non-nil PathStep that reports a nil Type.
// Last returns the last [PathStep] in the Path.
// If the path is empty, this returns a non-nil [PathStep]
// that reports a nil [PathStep.Type].
func (pa Path) Last() PathStep {
return pa.Index(-1)
}
@ -79,7 +85,8 @@ func (pa Path) Last() PathStep {
// Index returns the ith step in the Path and supports negative indexing.
// A negative index starts counting from the tail of the Path such that -1
// refers to the last step, -2 refers to the second-to-last step, and so on.
// If index is invalid, this returns a non-nil PathStep that reports a nil Type.
// If index is invalid, this returns a non-nil [PathStep]
// that reports a nil [PathStep.Type].
func (pa Path) Index(i int) PathStep {
if i < 0 {
i = len(pa) + i
@ -168,7 +175,8 @@ func (ps pathStep) String() string {
return fmt.Sprintf("{%s}", s)
}
// StructField represents a struct field access on a field called Name.
// StructField is a [PathStep] that represents a struct field access
// on a field called [StructField.Name].
type StructField struct{ *structField }
type structField struct {
pathStep
@ -204,10 +212,11 @@ func (sf StructField) String() string { return fmt.Sprintf(".%s", sf.name) }
func (sf StructField) Name() string { return sf.name }
// Index is the index of the field in the parent struct type.
// See reflect.Type.Field.
// See [reflect.Type.Field].
func (sf StructField) Index() int { return sf.idx }
// SliceIndex is an index operation on a slice or array at some index Key.
// SliceIndex is a [PathStep] that represents an index operation on
// a slice or array at some index [SliceIndex.Key].
type SliceIndex struct{ *sliceIndex }
type sliceIndex struct {
pathStep
@ -247,12 +256,12 @@ func (si SliceIndex) Key() int {
// all of the indexes to be shifted. If an index is -1, then that
// indicates that the element does not exist in the associated slice.
//
// Key is guaranteed to return -1 if and only if the indexes returned
// by SplitKeys are not the same. SplitKeys will never return -1 for
// [SliceIndex.Key] is guaranteed to return -1 if and only if the indexes
// returned by SplitKeys are not the same. SplitKeys will never return -1 for
// both indexes.
func (si SliceIndex) SplitKeys() (ix, iy int) { return si.xkey, si.ykey }
// MapIndex is an index operation on a map at some index Key.
// MapIndex is a [PathStep] that represents an index operation on a map at some index Key.
type MapIndex struct{ *mapIndex }
type mapIndex struct {
pathStep
@ -266,7 +275,7 @@ func (mi MapIndex) String() string { return fmt.Sprintf("[%#v]",
// Key is the value of the map key.
func (mi MapIndex) Key() reflect.Value { return mi.key }
// Indirect represents pointer indirection on the parent type.
// Indirect is a [PathStep] that represents pointer indirection on the parent type.
type Indirect struct{ *indirect }
type indirect struct {
pathStep
@ -276,7 +285,7 @@ func (in Indirect) Type() reflect.Type { return in.typ }
func (in Indirect) Values() (vx, vy reflect.Value) { return in.vx, in.vy }
func (in Indirect) String() string { return "*" }
// TypeAssertion represents a type assertion on an interface.
// TypeAssertion is a [PathStep] that represents a type assertion on an interface.
type TypeAssertion struct{ *typeAssertion }
type typeAssertion struct {
pathStep
@ -286,7 +295,8 @@ func (ta TypeAssertion) Type() reflect.Type { return ta.typ }
func (ta TypeAssertion) Values() (vx, vy reflect.Value) { return ta.vx, ta.vy }
func (ta TypeAssertion) String() string { return fmt.Sprintf(".(%v)", value.TypeString(ta.typ, false)) }
// Transform is a transformation from the parent type to the current type.
// Transform is a [PathStep] that represents a transformation
// from the parent type to the current type.
type Transform struct{ *transform }
type transform struct {
pathStep
@ -297,13 +307,13 @@ func (tf Transform) Type() reflect.Type { return tf.typ }
func (tf Transform) Values() (vx, vy reflect.Value) { return tf.vx, tf.vy }
func (tf Transform) String() string { return fmt.Sprintf("%s()", tf.trans.name) }
// Name is the name of the Transformer.
// Name is the name of the [Transformer].
func (tf Transform) Name() string { return tf.trans.name }
// Func is the function pointer to the transformer function.
func (tf Transform) Func() reflect.Value { return tf.trans.fnc }
// Option returns the originally constructed Transformer option.
// Option returns the originally constructed [Transformer] option.
// The == operator can be used to detect the exact option used.
func (tf Transform) Option() Option { return tf.trans }

View File

@ -199,7 +199,7 @@ func (opts formatOptions) FormatValue(v reflect.Value, parentKind reflect.Kind,
break
}
sf := t.Field(i)
if supportExporters && !isExported(sf.Name) {
if !isExported(sf.Name) {
vv = retrieveUnexportedField(v, sf, true)
}
s := opts.WithTypeMode(autoType).FormatValue(vv, t.Kind(), ptrs)

View File

@ -7,8 +7,8 @@
package imports // import "golang.org/x/tools/imports"
import (
"io/ioutil"
"log"
"os"
"golang.org/x/tools/internal/gocommand"
intimp "golang.org/x/tools/internal/imports"
@ -44,7 +44,7 @@ var LocalPrefix string
func Process(filename string, src []byte, opt *Options) ([]byte, error) {
var err error
if src == nil {
src, err = ioutil.ReadFile(filename)
src, err = os.ReadFile(filename)
if err != nil {
return nil, err
}

View File

@ -8,7 +8,6 @@
package fastwalk
import (
"io/ioutil"
"os"
)
@ -17,16 +16,20 @@ import (
// If fn returns a non-nil error, readDir returns with that error
// immediately.
func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) error) error {
fis, err := ioutil.ReadDir(dirName)
fis, err := os.ReadDir(dirName)
if err != nil {
return err
}
skipFiles := false
for _, fi := range fis {
if fi.Mode().IsRegular() && skipFiles {
info, err := fi.Info()
if err != nil {
return err
}
if info.Mode().IsRegular() && skipFiles {
continue
}
if err := fn(dirName, fi.Name(), fi.Mode()&os.ModeType); err != nil {
if err := fn(dirName, fi.Name(), info.Mode()&os.ModeType); err != nil {
if err == ErrSkipFiles {
skipFiles = true
continue

View File

@ -13,6 +13,7 @@ import (
"go/build"
"go/parser"
"go/token"
"io/fs"
"io/ioutil"
"os"
"path"
@ -107,7 +108,7 @@ func parseOtherFiles(fset *token.FileSet, srcDir, filename string) []*ast.File {
considerTests := strings.HasSuffix(filename, "_test.go")
fileBase := filepath.Base(filename)
packageFileInfos, err := ioutil.ReadDir(srcDir)
packageFileInfos, err := os.ReadDir(srcDir)
if err != nil {
return nil
}
@ -1469,11 +1470,11 @@ func VendorlessPath(ipath string) string {
func loadExportsFromFiles(ctx context.Context, env *ProcessEnv, dir string, includeTest bool) (string, []string, error) {
// Look for non-test, buildable .go files which could provide exports.
all, err := ioutil.ReadDir(dir)
all, err := os.ReadDir(dir)
if err != nil {
return "", nil, err
}
var files []os.FileInfo
var files []fs.DirEntry
for _, fi := range all {
name := fi.Name()
if !strings.HasSuffix(name, ".go") || (!includeTest && strings.HasSuffix(name, "_test.go")) {

View File

@ -9,7 +9,6 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
@ -265,7 +264,7 @@ func (r *ModuleResolver) findPackage(importPath string) (*gocommand.ModuleJSON,
}
// Not cached. Read the filesystem.
pkgFiles, err := ioutil.ReadDir(pkgDir)
pkgFiles, err := os.ReadDir(pkgDir)
if err != nil {
continue
}
@ -370,7 +369,7 @@ func (r *ModuleResolver) dirIsNestedModule(dir string, mod *gocommand.ModuleJSON
func (r *ModuleResolver) modInfo(dir string) (modDir string, modName string) {
readModName := func(modFile string) string {
modBytes, err := ioutil.ReadFile(modFile)
modBytes, err := os.ReadFile(modFile)
if err != nil {
return ""
}

View File

@ -171,15 +171,10 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,
ID: http2.SettingMaxFrameSize,
Val: http2MaxFrameLen,
}}
// TODO(zhaoq): Have a better way to signal "no limit" because 0 is
// permitted in the HTTP2 spec.
maxStreams := config.MaxStreams
if maxStreams == 0 {
maxStreams = math.MaxUint32
} else {
if config.MaxStreams != math.MaxUint32 {
isettings = append(isettings, http2.Setting{
ID: http2.SettingMaxConcurrentStreams,
Val: maxStreams,
Val: config.MaxStreams,
})
}
dynamicWindow := true
@ -258,7 +253,7 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,
framer: framer,
readerDone: make(chan struct{}),
writerDone: make(chan struct{}),
maxStreams: maxStreams,
maxStreams: config.MaxStreams,
inTapHandle: config.InTapHandle,
fc: &trInFlow{limit: uint32(icwz)},
state: reachable,

View File

@ -115,12 +115,6 @@ type serviceInfo struct {
mdata any
}
type serverWorkerData struct {
st transport.ServerTransport
wg *sync.WaitGroup
stream *transport.Stream
}
// Server is a gRPC server to serve RPC requests.
type Server struct {
opts serverOptions
@ -145,7 +139,7 @@ type Server struct {
channelzID *channelz.Identifier
czData *channelzData
serverWorkerChannel chan *serverWorkerData
serverWorkerChannel chan func()
}
type serverOptions struct {
@ -179,6 +173,7 @@ type serverOptions struct {
}
var defaultServerOptions = serverOptions{
maxConcurrentStreams: math.MaxUint32,
maxReceiveMessageSize: defaultServerMaxReceiveMessageSize,
maxSendMessageSize: defaultServerMaxSendMessageSize,
connectionTimeout: 120 * time.Second,
@ -404,6 +399,9 @@ func MaxSendMsgSize(m int) ServerOption {
// MaxConcurrentStreams returns a ServerOption that will apply a limit on the number
// of concurrent streams to each ServerTransport.
func MaxConcurrentStreams(n uint32) ServerOption {
if n == 0 {
n = math.MaxUint32
}
return newFuncServerOption(func(o *serverOptions) {
o.maxConcurrentStreams = n
})
@ -605,24 +603,19 @@ const serverWorkerResetThreshold = 1 << 16
// [1] https://github.com/golang/go/issues/18138
func (s *Server) serverWorker() {
for completed := 0; completed < serverWorkerResetThreshold; completed++ {
data, ok := <-s.serverWorkerChannel
f, ok := <-s.serverWorkerChannel
if !ok {
return
}
s.handleSingleStream(data)
f()
}
go s.serverWorker()
}
func (s *Server) handleSingleStream(data *serverWorkerData) {
defer data.wg.Done()
s.handleStream(data.st, data.stream, s.traceInfo(data.st, data.stream))
}
// initServerWorkers creates worker goroutines and a channel to process incoming
// connections to reduce the time spent overall on runtime.morestack.
func (s *Server) initServerWorkers() {
s.serverWorkerChannel = make(chan *serverWorkerData)
s.serverWorkerChannel = make(chan func())
for i := uint32(0); i < s.opts.numServerWorkers; i++ {
go s.serverWorker()
}
@ -982,21 +975,26 @@ func (s *Server) serveStreams(st transport.ServerTransport) {
defer st.Close(errors.New("finished serving streams for the server transport"))
var wg sync.WaitGroup
streamQuota := newHandlerQuota(s.opts.maxConcurrentStreams)
st.HandleStreams(func(stream *transport.Stream) {
wg.Add(1)
streamQuota.acquire()
f := func() {
defer streamQuota.release()
defer wg.Done()
s.handleStream(st, stream, s.traceInfo(st, stream))
}
if s.opts.numServerWorkers > 0 {
data := &serverWorkerData{st: st, wg: &wg, stream: stream}
select {
case s.serverWorkerChannel <- data:
case s.serverWorkerChannel <- f:
return
default:
// If all stream workers are busy, fallback to the default code path.
}
}
go func() {
defer wg.Done()
s.handleStream(st, stream, s.traceInfo(st, stream))
}()
go f()
}, func(ctx context.Context, method string) context.Context {
if !EnableTracing {
return ctx
@ -2091,3 +2089,34 @@ func validateSendCompressor(name, clientCompressors string) error {
}
return fmt.Errorf("client does not support compressor %q", name)
}
// atomicSemaphore implements a blocking, counting semaphore. acquire should be
// called synchronously; release may be called asynchronously.
type atomicSemaphore struct {
n atomic.Int64
wait chan struct{}
}
func (q *atomicSemaphore) acquire() {
if q.n.Add(-1) < 0 {
// We ran out of quota. Block until a release happens.
<-q.wait
}
}
func (q *atomicSemaphore) release() {
// N.B. the "<= 0" check below should allow for this to work with multiple
// concurrent calls to acquire, but also note that with synchronous calls to
// acquire, as our system does, n will never be less than -1. There are
// fairness issues (queuing) to consider if this was to be generalized.
if q.n.Add(1) <= 0 {
// An acquire was waiting on us. Unblock it.
q.wait <- struct{}{}
}
}
func newHandlerQuota(n uint32) *atomicSemaphore {
a := &atomicSemaphore{wait: make(chan struct{}, 1)}
a.n.Store(int64(n))
return a
}

View File

@ -19,4 +19,4 @@
package grpc
// Version is the current grpc version.
const Version = "1.58.2"
const Version = "1.58.3"

View File

@ -53,6 +53,7 @@ func (testHelper) ReadySubscriptionStatus() *messagingv1.SubscriptionStatus {
ss.MarkChannelReady()
ss.MarkReferencesResolved()
ss.MarkAddedToChannel()
ss.MarkOIDCIdentityCreatedSucceeded()
return ss
}

View File

@ -22,7 +22,7 @@ import (
// SubCondSet is a condition set with Ready as the happy condition and
// ReferencesResolved and ChannelReady as the dependent conditions.
var SubCondSet = apis.NewLivingConditionSet(SubscriptionConditionReferencesResolved, SubscriptionConditionAddedToChannel, SubscriptionConditionChannelReady)
var SubCondSet = apis.NewLivingConditionSet(SubscriptionConditionReferencesResolved, SubscriptionConditionAddedToChannel, SubscriptionConditionChannelReady, SubscriptionConditionOIDCIdentityCreated)
const (
// SubscriptionConditionReady has status True when all subconditions below have been set to True.
@ -37,6 +37,8 @@ const (
// SubscriptionConditionChannelReady has status True when the channel has marked the subscriber as 'ready'
SubscriptionConditionChannelReady apis.ConditionType = "ChannelReady"
SubscriptionConditionOIDCIdentityCreated apis.ConditionType = "OIDCIdentityCreated"
)
// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
@ -113,3 +115,19 @@ func (ss *SubscriptionStatus) MarkChannelUnknown(reason, messageFormat string, m
func (ss *SubscriptionStatus) MarkNotAddedToChannel(reason, messageFormat string, messageA ...interface{}) {
SubCondSet.Manage(ss).MarkFalse(SubscriptionConditionAddedToChannel, reason, messageFormat, messageA...)
}
func (ss *SubscriptionStatus) MarkOIDCIdentityCreatedSucceeded() {
SubCondSet.Manage(ss).MarkTrue(SubscriptionConditionOIDCIdentityCreated)
}
func (ss *SubscriptionStatus) MarkOIDCIdentityCreatedSucceededWithReason(reason, messageFormat string, messageA ...interface{}) {
SubCondSet.Manage(ss).MarkTrueWithReason(SubscriptionConditionOIDCIdentityCreated, reason, messageFormat, messageA...)
}
func (ss *SubscriptionStatus) MarkOIDCIdentityCreatedFailed(reason, messageFormat string, messageA ...interface{}) {
SubCondSet.Manage(ss).MarkFalse(SubscriptionConditionOIDCIdentityCreated, reason, messageFormat, messageA...)
}
func (ss *SubscriptionStatus) MarkOIDCIdentityCreatedUnknown(reason, messageFormat string, messageA ...interface{}) {
SubCondSet.Manage(ss).MarkUnknown(SubscriptionConditionOIDCIdentityCreated, reason, messageFormat, messageA...)
}

View File

@ -37,12 +37,16 @@ const (
// ApiServerConditionSufficientPermissions has status True when the ApiServerSource has sufficient permissions to access resources.
ApiServerConditionSufficientPermissions apis.ConditionType = "SufficientPermissions"
// ApiServerConditionOIDCIdentityCreated has status True when the ApiServerSource has created an OIDC identity.
ApiServerConditionOIDCIdentityCreated apis.ConditionType = "OIDCIdentityCreated"
)
var apiserverCondSet = apis.NewLivingConditionSet(
ApiServerConditionSinkProvided,
ApiServerConditionDeployed,
ApiServerConditionSufficientPermissions,
ApiServerConditionOIDCIdentityCreated,
)
// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
@ -126,3 +130,19 @@ func (s *ApiServerSourceStatus) MarkNoSufficientPermissions(reason, messageForma
func (s *ApiServerSourceStatus) IsReady() bool {
return apiserverCondSet.Manage(s).IsHappy()
}
func (s *ApiServerSourceStatus) MarkOIDCIdentityCreatedSucceeded() {
apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionOIDCIdentityCreated)
}
func (s *ApiServerSourceStatus) MarkOIDCIdentityCreatedSucceededWithReason(reason, messageFormat string, messageA ...interface{}) {
apiserverCondSet.Manage(s).MarkTrueWithReason(ApiServerConditionOIDCIdentityCreated, reason, messageFormat, messageA...)
}
func (s *ApiServerSourceStatus) MarkOIDCIdentityCreatedFailed(reason, messageFormat string, messageA ...interface{}) {
apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionOIDCIdentityCreated, reason, messageFormat, messageA...)
}
func (s *ApiServerSourceStatus) MarkOIDCIdentityCreatedUnknown(reason, messageFormat string, messageA ...interface{}) {
apiserverCondSet.Manage(s).MarkUnknown(ApiServerConditionOIDCIdentityCreated, reason, messageFormat, messageA...)
}

View File

@ -35,11 +35,15 @@ const (
// PingSourceConditionDeployed has status True when the PingSource has had it's receive adapter deployment created.
PingSourceConditionDeployed apis.ConditionType = "Deployed"
// PingSourceConditionOIDCIdentityCreated has status True when the PingSource has had it's OIDC identity created.
PingSourceConditionOIDCIdentityCreated apis.ConditionType = "OIDCIdentityCreated"
)
var PingSourceCondSet = apis.NewLivingConditionSet(
PingSourceConditionSinkProvided,
PingSourceConditionDeployed)
PingSourceConditionDeployed,
PingSourceConditionOIDCIdentityCreated)
const (
// PingSourceEventType is the default PingSource CloudEvent type.
@ -122,3 +126,19 @@ func (s *PingSourceStatus) PropagateDeploymentAvailability(d *appsv1.Deployment)
PingSourceCondSet.Manage(s).MarkUnknown(PingSourceConditionDeployed, "DeploymentUnavailable", "The Deployment '%s' is unavailable.", d.Name)
}
}
func (s *PingSourceStatus) MarkOIDCIdentityCreatedSucceeded() {
PingSourceCondSet.Manage(s).MarkTrue(PingSourceConditionOIDCIdentityCreated)
}
func (s *PingSourceStatus) MarkOIDCIdentityCreatedSucceededWithReason(reason, messageFormat string, messageA ...interface{}) {
PingSourceCondSet.Manage(s).MarkTrueWithReason(PingSourceConditionOIDCIdentityCreated, reason, messageFormat, messageA...)
}
func (s *PingSourceStatus) MarkOIDCIdentityCreatedFailed(reason, messageFormat string, messageA ...interface{}) {
PingSourceCondSet.Manage(s).MarkFalse(PingSourceConditionOIDCIdentityCreated, reason, messageFormat, messageA...)
}
func (s *PingSourceStatus) MarkOIDCIdentityCreatedUnknown(reason, messageFormat string, messageA ...interface{}) {
PingSourceCondSet.Manage(s).MarkUnknown(PingSourceConditionOIDCIdentityCreated, reason, messageFormat, messageA...)
}

View File

@ -44,12 +44,8 @@ func (c *ClientConfig) InitFlags(fs *flag.FlagSet) {
fs.StringVar(&c.ServerURL, "server", "",
"The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
if f := fs.Lookup("kubeconfig"); f != nil {
c.Kubeconfig = f.Value.String()
} else {
fs.StringVar(&c.Kubeconfig, "kubeconfig", os.Getenv("KUBECONFIG"),
"Path to a kubeconfig. Only required if out-of-cluster.")
}
fs.StringVar(&c.Kubeconfig, "kubeconfig", os.Getenv("KUBECONFIG"),
"Path to a kubeconfig. Only required if out-of-cluster.")
fs.IntVar(&c.Burst, "kube-api-burst", int(envVarOrDefault("KUBE_API_BURST", 0)), "Maximum burst for throttle.")

View File

@ -59,13 +59,11 @@ func newH2CTransport(disableCompression bool) http.RoundTripper {
// newH2Transport constructs a neew H2 transport. That transport will handles HTTPS traffic
// with TLS config.
func newH2Transport(disableCompression bool, tlsConf *tls.Config) http.RoundTripper {
func newH2Transport(disableCompression bool, tlsContext DialTLSContextFunc) http.RoundTripper {
return &http2.Transport{
DisableCompression: disableCompression,
DialTLS: func(netw, addr string, tlsConf *tls.Config) (net.Conn, error) {
return DialTLSWithBackOff(context.Background(),
netw, addr, tlsConf)
DialTLSContext: func(ctx context.Context, network, addr string, cfg *tls.Config) (net.Conn, error) {
return tlsContext(ctx, network, addr)
},
TLSClientConfig: tlsConf,
}
}

View File

@ -127,16 +127,17 @@ func newHTTPTransport(disableKeepAlives, disableCompression bool, maxIdle, maxId
return transport
}
func newHTTPSTransport(disableKeepAlives, disableCompression bool, maxIdle, maxIdlePerHost int, tlsConf *tls.Config) http.RoundTripper {
type DialTLSContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)
func newHTTPSTransport(disableKeepAlives, disableCompression bool, maxIdle, maxIdlePerHost int, tlsContext DialTLSContextFunc) http.RoundTripper {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.DialContext = DialWithBackOff
transport.DisableKeepAlives = disableKeepAlives
transport.MaxIdleConns = maxIdle
transport.MaxIdleConnsPerHost = maxIdlePerHost
transport.ForceAttemptHTTP2 = false
transport.DisableCompression = disableCompression
transport.DialTLSContext = tlsContext
transport.TLSClientConfig = tlsConf
return transport
}
@ -148,11 +149,11 @@ func NewProberTransport() http.RoundTripper {
NewH2CTransport())
}
// NewProxyAutoTLSTransport is same with NewProxyAutoTransport but it has tls.Config to create HTTPS request.
func NewProxyAutoTLSTransport(maxIdle, maxIdlePerHost int, tlsConf *tls.Config) http.RoundTripper {
// NewProxyAutoTLSTransport is same with NewProxyAutoTransport but it has DialTLSContextFunc to create HTTPS request.
func NewProxyAutoTLSTransport(maxIdle, maxIdlePerHost int, tlsContext DialTLSContextFunc) http.RoundTripper {
return newAutoTransport(
newHTTPSTransport(false /*disable keep-alives*/, true /*disable auto-compression*/, maxIdle, maxIdlePerHost, tlsConf),
newH2Transport(true /*disable auto-compression*/, tlsConf))
newHTTPSTransport(false /*disable keep-alives*/, true /*disable auto-compression*/, maxIdle, maxIdlePerHost, tlsContext),
newH2Transport(true /*disable auto-compression*/, tlsContext))
}
// NewAutoTransport creates a RoundTripper that can use appropriate transport

30
vendor/modules.txt vendored
View File

@ -116,7 +116,7 @@ github.com/google/gnostic/extensions
github.com/google/gnostic/jsonschema
github.com/google/gnostic/openapiv2
github.com/google/gnostic/openapiv3
# github.com/google/go-cmp v0.5.9
# github.com/google/go-cmp v0.6.0
## explicit; go 1.13
github.com/google/go-cmp/cmp
github.com/google/go-cmp/cmp/cmpopts
@ -345,8 +345,8 @@ go.uber.org/zap/internal/exit
go.uber.org/zap/internal/pool
go.uber.org/zap/internal/stacktrace
go.uber.org/zap/zapcore
# golang.org/x/mod v0.12.0
## explicit; go 1.17
# golang.org/x/mod v0.13.0
## explicit; go 1.18
golang.org/x/mod/internal/lazyregexp
golang.org/x/mod/module
golang.org/x/mod/semver
@ -392,7 +392,7 @@ golang.org/x/text/unicode/norm
# golang.org/x/time v0.3.0
## explicit
golang.org/x/time/rate
# golang.org/x/tools v0.13.0
# golang.org/x/tools v0.14.0
## explicit; go 1.18
golang.org/x/tools/go/ast/astutil
golang.org/x/tools/imports
@ -409,7 +409,7 @@ golang.org/x/tools/internal/typeparams
# gomodules.xyz/jsonpatch/v2 v2.4.0
## explicit; go 1.20
gomodules.xyz/jsonpatch/v2
# google.golang.org/api v0.145.0
# google.golang.org/api v0.147.0
## explicit; go 1.19
google.golang.org/api/support/bundler
# google.golang.org/appengine v1.6.7
@ -421,16 +421,16 @@ google.golang.org/appengine/internal/log
google.golang.org/appengine/internal/remote_api
google.golang.org/appengine/internal/urlfetch
google.golang.org/appengine/urlfetch
# google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb
# google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97
## explicit; go 1.19
google.golang.org/genproto/protobuf/field_mask
# google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb
# google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97
## explicit; go 1.19
google.golang.org/genproto/googleapis/api/httpbody
# google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13
# google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c
## explicit; go 1.19
google.golang.org/genproto/googleapis/rpc/status
# google.golang.org/grpc v1.58.2
# google.golang.org/grpc v1.58.3
## explicit; go 1.19
google.golang.org/grpc
google.golang.org/grpc/attributes
@ -949,10 +949,10 @@ k8s.io/utils/net
k8s.io/utils/pointer
k8s.io/utils/strings/slices
k8s.io/utils/trace
# knative.dev/client-pkg v0.0.0-20231010132217-9ed2a9604c41
# knative.dev/client-pkg v0.0.0-20231020123408-9cea6f6e36ce
## explicit; go 1.18
knative.dev/client-pkg/pkg/kn/plugin
# knative.dev/eventing v0.38.1-0.20231011142145-da0fba3c161a
# knative.dev/eventing v0.38.1-0.20231019170735-4d14c2126a20
## explicit; go 1.19
knative.dev/eventing/pkg/apis/config
knative.dev/eventing/pkg/apis/duck
@ -981,10 +981,10 @@ knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1
knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1/fake
knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta2
knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta2/fake
# knative.dev/hack v0.0.0-20231010131532-fc76874b28c6
# knative.dev/hack v0.0.0-20231016131700-2c938d4918da
## explicit; go 1.18
knative.dev/hack
# knative.dev/networking v0.0.0-20231011064411-6c502de01ce6
# knative.dev/networking v0.0.0-20231017124814-2a7676e912b7
## explicit; go 1.18
knative.dev/networking/pkg
knative.dev/networking/pkg/apis/networking
@ -999,7 +999,7 @@ knative.dev/networking/pkg/http/probe
knative.dev/networking/pkg/http/proxy
knative.dev/networking/pkg/http/stats
knative.dev/networking/pkg/k8s
# knative.dev/pkg v0.0.0-20231011202506-948f5f57818a
# knative.dev/pkg v0.0.0-20231017113806-d6ab72900ea5
## explicit; go 1.18
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
@ -1049,7 +1049,7 @@ knative.dev/pkg/tracing/config
knative.dev/pkg/tracing/propagation
knative.dev/pkg/tracing/propagation/tracecontextb3
knative.dev/pkg/tracker
# knative.dev/serving v0.38.1-0.20231011210335-6703812f1314
# knative.dev/serving v0.38.1-0.20231020131030-425abcb95f5a
## explicit; go 1.18
knative.dev/serving/pkg/apis/autoscaling
knative.dev/serving/pkg/apis/autoscaling/v1alpha1