Skip to content

Commit

Permalink
correct state migration issue
Browse files Browse the repository at this point in the history
  • Loading branch information
georgekaz committed Jan 12, 2024
1 parent a8ed95c commit 811cfcb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions github/migrate_github_branch_protection.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package github

import "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func resourceGithubBranchProtectionV0() *schema.Resource {
return &schema.Resource{
Expand Down Expand Up @@ -64,10 +66,10 @@ func resourceGithubBranchProtectionUpgradeV1(rawState map[string]interface{}, me
}

if v, ok := rawState["push_restrictions"]; ok {
rawState["restrict_pushes"] = map[string]interface{}{
rawState["restrict_pushes"] = []interface{}{map[string]interface{}{
"blocks_creations": blocksCreations,
"push_allowances": v,
}
}}
}

delete(rawState, "blocks_creations")
Expand Down
4 changes: 2 additions & 2 deletions github/resource_github_branch_protection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,10 +909,10 @@ func testGithubBranchProtectionStateDataV1() map[string]interface{} {
}

func testGithubBranchProtectionStateDataV2() map[string]interface{} {
restrictions := map[string]interface{}{
restrictions := []interface{}{map[string]interface{}{
"blocks_creations": true,
"push_allowances": [...]string{"/example-user"},
}
}}
return map[string]interface{}{
"restrict_pushes": restrictions,
}
Expand Down

0 comments on commit 811cfcb

Please sign in to comment.