Skip to content

chore: Refactor provider pattern and docs - #3440

Merged
deiga merged 2 commits into
integrations:mainfrom
stevehipwell:refactor-provider-docs
May 21, 2026
Merged

deiga merged 2 commits into
integrations:mainfrom
stevehipwell:refactor-provider-docs

Conversation

@stevehipwell

Copy link
Copy Markdown
Collaborator

Closes #3247


Before the change?

  • The provider configuration wasn't very idiomatic
  • The provider schema docs were manually written
  • retryDelay is incorrectly set to the value of read_delay_ms

After the change?

  • The provider configuration is more idiomatic (more work to do on this)
  • The provider schema docs are auto generated
  • retryDelay is correctly set to the value of retry_delay_ms

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@stevehipwell stevehipwell added this to the v6.13.0 milestone May 21, 2026
@stevehipwell
stevehipwell requested review from Copilot and deiga May 21, 2026 11:00
@stevehipwell stevehipwell self-assigned this May 21, 2026
@stevehipwell stevehipwell added the Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR label May 21, 2026
@github-actions

Copy link
Copy Markdown

👋 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 Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@stevehipwell
stevehipwell force-pushed the refactor-provider-docs branch from 78f7024 to 1540656 Compare May 21, 2026 11:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the provider entrypoint to a more idiomatic NewProvider() factory pattern, switches provider documentation to rely on tfplugindocs-generated schema output, and fixes a configuration bug where retryDelay was incorrectly sourced from read_delay_ms.

Changes:

  • Refactor provider construction to NewProvider() and wire it through main, unit tests, and acceptance test provider factories.
  • Replace manually-maintained provider schema docs with generated SchemaMarkdown in templates and docs/index.md.
  • Fix retry_delay_ms handling and consolidate default retryable status code logic under getDefaultRetryableErrors().

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
templates/index.md.tmpl Updates provider landing page template and injects generated schema markdown.
main.go Serves provider using ProviderAddr and github.NewProvider() factory.
github/util_repo.go Removes old default-retryable-errors helper from util file.
github/transport.go Switches retry transport default errors function to new name/location.
github/provider.go Refactors provider schema definition and configuration; fixes retry_delay_ms source.
github/provider_test.go Updates tests to use NewProvider()() instead of Provider().
github/data_source_github_app_token.go Replaces references to removed descriptions map with inline descriptions.
github/acc_test.go Updates acceptance provider factory to use NewProvider()().
examples/provider/provider.tf Adds updated provider example with required_providers and a basic data source.
examples/provider/example_1.tf Removes old provider example file.
examples/provider/example_2.tf Removes old provider example file.
docs/index.md Updates published docs to new narrative + tfplugindocs-generated schema section.
Comments suppressed due to low confidence (1)

github/provider.go:402

  • This change fixes a configuration bug where retryDelay was previously sourced from read_delay_ms. There’s no regression test exercising retry_delay_ms behavior (e.g., setting read_delay_ms and retry_delay_ms to different values and asserting the resulting retry delay). Adding a test would help prevent this from reoccurring.
		retryDelay, _ := d.Get("retry_delay_ms").(int)
		if retryDelay < 0 {
			return nil, diag.Errorf("retry_delay_ms must be greater than or equal to 0ms")
		}
		log.Printf("[DEBUG] Setting retry_delay_ms to %d", retryDelay)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread github/provider.go Resolved
Comment thread github/provider.go Resolved

@robert-crandall robert-crandall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch on the retry_delay_ms bug! Thanks for the cleanup!

@stevehipwell

Copy link
Copy Markdown
Collaborator Author

Nice catch on the retry_delay_ms bug! Thanks for the cleanup!

@deiga also caught this, and #3247 was previously opened to fix it, but with the new strict linter it needed rework and the contributor hasn't rebased so I decided to fix it here.

@deiga deiga left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! @robert-crandall could you review and approve?

@deiga
deiga merged commit 7b27420 into integrations:main May 21, 2026
10 checks passed
@stevehipwell
stevehipwell deleted the refactor-provider-docs branch May 21, 2026 17:44
austenstone pushed a commit to austenstone/terraform-provider-github that referenced this pull request Jun 9, 2026
austenstone pushed a commit to austenstone/terraform-provider-github that referenced this pull request Jun 9, 2026
corymhall pushed a commit to pulumi/pulumi-github that referenced this pull request Aug 14, 2026
Unblocks the nightly `upgrade-provider` job and pulls in upstream
v6.13.0.

## Why this was stuck

Upstream v6.13.0 refactored the provider entry point in
[#3440](integrations/terraform-provider-github#3440),
replacing the parameterless `github.Provider()` with
`github.NewProvider(version, commit)`, which returns the provider
factory.

The nightly [Upgrade
provider](https://github.com/pulumi/pulumi-github/actions/workflows/upgrade-provider.yml)
job rebases onto the new tag fine, then dies in codegen:

```
./scripts/upstream.sh rebase -o refs/tags/v6.13.0: done
error: upgrade-provider executed `make tfgen` which failed: exit status 2:
./resources.go:78:33: undefined: github.Provider
make: *** [Makefile:323: bin/pulumi-tfgen-github] Error 1
```

It has failed every night since v6.13.0 was released on 2026-07-08, so
the bridge is still pinned to upstream v6.12.1 and none of the fixes
below have shipped.

## Changes

- `provider/resources.go`: use `github.NewProvider(version.Version,
"")()`. `version` and `commit` only feed the upstream User-Agent and
debug logging; the bridge appends its own Pulumi User-Agent, so the
commit is left empty. This is the only hand-written change.
- `upstream`: v6.12.1 → v6.13.0 (via `upstream.sh checkout` / `rebase -o
refs/tags/v6.13.0` / `check_in`).
- Regenerated schema, all five SDKs, and `docs/_index.md`.

## Notable upstream fixes pulled in

- **`github_team_repository` delete now treats a 404 from GitHub as a
successful delete**
([#3524](integrations/terraform-provider-github#3524)).
Previously the 404 branch only recovered from repository *renames*: it
re-read the repo and retried the delete only when `.GetName()` differed.
A repository transferred to a **different organization** keeps its name,
so the retry was skipped and the original 404 surfaced as a hard error.
Any stack still holding that resource in state is then permanently
wedged — every subsequent update fails on the same undeletable resource,
and the only escape is `pulumi state delete`.
- Fixes a nil-pointer panic in that same delete path when the API call
fails at the transport layer
([#3518](integrations/terraform-provider-github#3518)).
- `github_team_members` deletion is skipped when the parent team is
already gone
([#3461](integrations/terraform-provider-github#3461)).

## Schema impact

Additive — nothing removed or retyped (verified by diffing schema keys
against `master`):

- New provider config options: `cachePath`, `legacyClient`
- New resource properties: `BranchDefault.repositoryId`,
`BranchDefault.waitForRename`,
`RepositoryCollaborators.ownerConfigured`,
`RepositoryCustomProperty.repositoryId`, `TeamMembers.teamSlug`

The bulk of the schema and `docs/_index.md` diff is upstream's migration
to tfplugindocs
([#3380](integrations/terraform-provider-github#3380))
and its rewritten provider docs and examples
([#3440](integrations/terraform-provider-github#3440))
— restyled descriptions, and the overview example changing from
`github_membership` to `getRepository` because upstream replaced
`examples/provider/example_1.tf`/`example_2.tf` with a single
`provider.tf`.

## Verification

- `make tfgen` succeeds; example conversion 93.39% (1314/1407)
- All five SDKs generated; Go SDK compiles
- `dotnet build` not run locally (unrelated local NuGet source
misconfiguration) — leaving that to CI
- Acceptance tests not run locally

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Maintenance Any dependency, housekeeping, and clean up Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants