From 811cfcbdffe398a51d0a20573f19d4dcaaa44987 Mon Sep 17 00:00:00 2001 From: George Kaz <1391828+georgekaz@users.noreply.github.com> Date: Fri, 12 Jan 2024 00:47:46 +0000 Subject: [PATCH] correct state migration issue --- github/migrate_github_branch_protection.go | 8 +++++--- github/resource_github_branch_protection_test.go | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/github/migrate_github_branch_protection.go b/github/migrate_github_branch_protection.go index 19f0acf6b3..298d372200 100644 --- a/github/migrate_github_branch_protection.go +++ b/github/migrate_github_branch_protection.go @@ -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{ @@ -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") diff --git a/github/resource_github_branch_protection_test.go b/github/resource_github_branch_protection_test.go index f1e7cdd9c5..62ae6437c2 100644 --- a/github/resource_github_branch_protection_test.go +++ b/github/resource_github_branch_protection_test.go @@ -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, }