[BUG] Ensure autolink reference doesn't error when repo is renamed - #3271
[BUG] Ensure autolink reference doesn't error when repo is renamed#3271deiga wants to merge 19 commits into
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 |
ad1fdb7 to
00ea1c8
Compare
00ea1c8 to
458f672
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
Do we need a migration to add the repository ID and then rely on it or we just supporting it as a best effort?
458f672 to
852d646
Compare
852d646 to
50a9aa7
Compare
There was a problem hiding this comment.
Pull request overview
These provider review instructions are being used.
This PR fixes #3470 for github_repository_autolink_reference so that renaming a repository no longer forces the autolink reference to be destroyed and recreated (which previously errored). It adopts the provider's rename-safe convention: drop ForceNew from repository, add a computed repository_id, and wire up CustomizeDiff: diffRepository so replacement is only forced when the underlying repository ID actually changes. The CRUD handlers are also modernized to the *Context variants, and a state upgrader is added to backfill repository_id.
Changes:
- Convert CRUD to context-aware handlers, add a no-op
Update, extract the importer, and switch logging totflog. - Add
repository_id(computed), removeForceNewfromrepository, and addCustomizeDiff: diffRepository; add a state upgrader + migration to populaterepository_id. - Update acceptance tests to
statecheck/plancheck(incl. a rename scenario), add a migration unit test, and refresh docs/example.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| github/resource_github_repository_autolink_reference.go | Rename-safe schema (repository_id, no ForceNew, diffRepository), context CRUD, no-op Update; state upgrader registered with a version mismatch (blocking). |
| github/resource_github_repository_autolink_reference_migration.go | New V0 schema + state upgrade func that fetches and stores repository_id. |
| github/resource_github_repository_autolink_reference_migration_test.go | Unit test invoking the state upgrade function directly against a mocked API. |
| github/resource_github_repository_autolink_reference_test.go | Migrates checks to statecheck, adds a repository-rename in-place test. |
| templates/resources/repository_autolink_reference.md.tmpl | Docs template: updated repository description, adds repository_id. |
| docs/resources/repository_autolink_reference.md | Generated docs mirror the template/schema updates and visibility example. |
| examples/resources/repository_autolink_reference/example_1.tf | Example switched from deprecated private to visibility. |
Blocking finding: the added StateUpgrader uses Version: 0 while the resource already ships at SchemaVersion: 1, so it will never execute for existing state (which is already stamped v1). The version must be bumped to 2 with the upgrader registered at Version: 1 to actually backfill repository_id.
cf7ee3b to
4b95c1a
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
Just a quick review.
| parts := strings.Split(d.Id(), "/") | ||
| if len(parts) != 2 { | ||
| return nil, fmt.Errorf("invalid ID specified: supplied ID must be written as <repository>/<autolink_reference_id>") | ||
| } |
There was a problem hiding this comment.
I think the ID should be migrated as part of the schema migration so it can use the ID functions.
There was a problem hiding this comment.
Since this is "just" the import ID, it doesn't need a migration, right?
4b95c1a to
aaa15da
Compare
aaa15da to
ba732c3
Compare
ba732c3 to
a66eaa4
Compare
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
a66eaa4 to
f1c9742
Compare
Resolves #3470
Before the change?
github_repository_autolink_referenceto be re-created and throw an errorAfter the change?
github_repository_autolink_referencePull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!