Repository navigation
feat: Add new gh client implementation - #3448
Conversation
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
69a5c44 to
4e54261
Compare
deiga
left a comment
There was a problem hiding this comment.
This is looking quite nice!
632524d to
ded4e69
Compare
|
@deiga I've addressed most of your comments. |
ce45d1f to
7d0de33
Compare
There was a problem hiding this comment.
Pull request overview
These provider review instructions are being used. This PR introduces a new opt-in GitHub client implementation for the Terraform provider, adding transport-level caching/rate-limit handling and refreshed client construction while preserving the legacy client path by default.
Changes:
- Adds
internal/ghclientwith anonymous, token, and GitHub App client sources plus shared transport/cache logic. - Updates provider configuration to support
legacy_clientandcache_path, and routes client setup throughconfigureProviderMeta. - Updates tests, docs, and acceptance-test workflows to exercise the new client path.
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
internal/ghclient/transport.go |
Adds composed OAuth/cache/logging/retry/rate-limit transport. |
internal/ghclient/transport_test.go |
Covers transport cloning and retry behavior. |
internal/ghclient/token.go |
Adds token-backed client source. |
internal/ghclient/token_test.go |
Tests token source client accessors. |
internal/ghclient/source.go |
Defines the shared client source interface. |
internal/ghclient/rest.go |
Adds REST client constructors. |
internal/ghclient/rest_test.go |
Tests REST client construction. |
internal/ghclient/options.go |
Defines client construction options. |
internal/ghclient/helpers_test.go |
Adds shared ghclient test helpers. |
internal/ghclient/graphql.go |
Adds GraphQL client constructors. |
internal/ghclient/graphql_test.go |
Tests GraphQL client construction. |
internal/ghclient/const.go |
Adds shared client timeout. |
internal/ghclient/cache.go |
Adds cache store creation. |
internal/ghclient/cache_test.go |
Tests cache path/ref behavior. |
internal/ghclient/app.go |
Adds GitHub App-backed client source and owner lookup. |
internal/ghclient/app_test.go |
Tests app source caching and installation lookup. |
internal/ghclient/anonymous.go |
Adds anonymous client source. |
internal/ghclient/anonymous_test.go |
Tests anonymous source client accessors. |
go.mod |
Adds new client/cache/rate-limit dependencies. |
go.sum |
Adds dependency checksums. |
github/provider.go |
Reworks provider configuration and new/legacy client setup. |
github/provider_test.go |
Updates provider/client configuration tests. |
github/data_source_github_user_external_identity.go |
Uses operation context for GraphQL query. |
github/data_source_github_ssh_keys.go |
Uses operation context for REST call. |
github/data_source_github_repository_test.go |
Adjusts repository data source acceptance precheck. |
github/data_source_github_organization_teams.go |
Uses operation context for GraphQL/REST calls. |
github/data_source_github_ip_ranges.go |
Uses operation context for REST call. |
github/data_source_github_codespaces_user_public_key_test.go |
Skips app-auth mode for unsupported test. |
github/data_source_github_branch_protection_rules.go |
Uses operation context for GraphQL query. |
github/config.go |
Extends provider config and routes Meta through new setup. |
github/config_test.go |
Removes relocated client meta tests. |
github/acc_test.go |
Extends acceptance-test config for new client/app auth. |
docs/index.md |
Documents new provider arguments and changed option behavior. |
CONTRIBUTING.md |
Updates acceptance-test setup for new client mode. |
.github/workflows/ghes-acceptance-tests.yaml |
Runs GHES acceptance tests with new client. |
.github/workflows/dotcom-acceptance-tests.yaml |
Runs dotcom acceptance tests with new client. |
e902e1d to
7f3fc86
Compare
Signed-off-by: Steve Hipwell <[email protected]>
6250854 to
21ce521
Compare
|
Where does this disable go-github's annoying rate limit check before hitting the transport layer? |
|
If you enable the new (experimental) client by setting |
* feat: Add new gh client implementation Signed-off-by: Steve Hipwell <[email protected]> * fixup! feat: Add new gh client implementation * fixup! feat: Add new gh client implementation * fixup! feat: Add new gh client implementation * fixup! feat: Add new gh client implementation * fixup! feat: Add new gh client implementation * fixup! feat: Add new gh client implementation * fixup! feat: Add new gh client implementation * fixup! feat: Add new gh client implementation * fixup! feat: Add new gh client implementation --------- Signed-off-by: Steve Hipwell <[email protected]>
The doc asserted the original innermost oauth2 placement gave token freshness "by accident" and cited the newTransport doc comment as evidence the ordering was unintended. Neither survives checking. The doc comment lists layers in construction order (oauth2, ghct, logging, retry), which matches the code exactly. Construction order is the reverse of execution order, but the comment never claims an execution order, so it is evidence of neither intent nor accident. Replace both with the one substantive datum from history: oauth2 and ghct were introduced in the same commit (e286cb0, integrations#3448) with ghct placed directly outside oauth2, so the cache could never see Authorization and the feature was non-functional from the commit that added it. State plainly that intent is not knowable from the repository and that the new ordering is chosen to satisfy both properties explicitly rather than to rely on either having been intended. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 1d014064-b027-4d89-9e5b-e1f9781bc039
Warning
This is a work in progress. There is a known issue for tests on resources that rely on other resources to mutate them not passing due to internal GitHub logic. These would be fixed by adopting a test strategy where the fixtures are created outside of Terraform.
Resolves #2925
Resolves #3103
Resolves #2709
Resolves #849
Before the change?
After the change?
legacy_client = falseprovider setting)cache_pathprovider settingghCLI authPull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!