authz: rename Validate to ValidateConnection, remove from constructors
Created by: bobheadxi
An alternative fix at what https://github.com/sourcegraph/sourcegraph/pull/30617 tries to solve (excessive GitHub API requests traced back to (*Provider).Validate()
at customers using groupsCacheTTL
: https://github.com/sourcegraph/customer/issues/658 )
- Rename
Validate
toValidateConnection(context.Context)
- See https://github.com/sourcegraph/sourcegraph/pull/30617#issuecomment-1032058894 - tl;dr all
Valdiate
implementations today make network requests and nothing else, so this change makes it clearer what is going on and allows the check to accept a context for cancellation etc.
- See https://github.com/sourcegraph/sourcegraph/pull/30617#issuecomment-1032058894 - tl;dr all
- Remove validation from default constructors
- Only a single call to
ProvidersFromConfig
actually uses the warnings returned, making all these calls toValidate
unnecessary.- In the single callsite that actually uses the returned warnings, I've added calls to
ValidateConnection
- In the single callsite that actually uses the returned warnings, I've added calls to
-
ProviderFromExternalService
is the other primary user of the various authz provider constructors e.g.github.NewAuthzProviders
, but it discardswarnings
, and validation problems are always appended towarnings
(see the removed calls in the PR diff)
- Only a single call to
Closes https://github.com/sourcegraph/sourcegraph/pull/30617
Remaining TODOs:
-
Main-dry-run passes: https://buildkite.com/sourcegraph/sourcegraph/builds/129954 -
Update docstrings on authz provider constructors to indicate only simple validation occurs on the constructors