-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch BranchProtection state migration (#594)
Fixes #586
- Loading branch information
Showing
7 changed files
with
225 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "upstream"] | ||
path = upstream | ||
url = https://github.com/integrations/terraform-provider-github.git | ||
ignore = dirty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/github/migrate_github_branch_protection.go b/github/migrate_github_branch_protection.go | ||
index 2eccae49..42dcc1f2 100644 | ||
--- a/github/migrate_github_branch_protection.go | ||
+++ b/github/migrate_github_branch_protection.go | ||
@@ -64,7 +64,9 @@ func resourceGithubBranchProtectionUpgradeV1(_ context.Context, rawState map[str | ||
var blocksCreations bool = false | ||
|
||
if v, ok := rawState["blocks_creations"]; ok { | ||
- blocksCreations = v.(bool) | ||
+ // Equate type errors as false. This is a work-around for | ||
+ // https://github.com/pulumi/pulumi-terraform-bridge/issues/1667. | ||
+ blocksCreations, _ = v.(bool) | ||
} | ||
|
||
if v, ok := rawState["push_restrictions"]; ok { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
package github_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/pulumi/providertest/replay" | ||
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge" | ||
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go" | ||
|
||
github "github.com/pulumi/pulumi-github/provider/v6" | ||
"github.com/pulumi/pulumi-github/provider/v6/pkg/version" | ||
) | ||
|
||
const repro586 = `[ | ||
{ | ||
"method": "/pulumirpc.ResourceProvider/Diff", | ||
"request": { | ||
"id": "BPR_kwDOLcEl984C1wZz", | ||
"urn": "urn:pulumi:dev::ts::github:index/branchProtection:BranchProtection::debug-pulumi-github-protection", | ||
"olds": { | ||
"__meta": "{\"schema_version\":\"1\"}", | ||
"allowsDeletions": false, | ||
"allowsForcePushes": false, | ||
"blocksCreations": false, | ||
"enforceAdmins": true, | ||
"forcePushBypassers": [], | ||
"id": "BPR_kwDOLcEl984C1wZz", | ||
"lockBranch": false, | ||
"pattern": "main", | ||
"pushRestrictions": [ | ||
"/iwahbe" | ||
], | ||
"repositoryId": "debug-pulumi-github", | ||
"requireConversationResolution": false, | ||
"requireSignedCommits": false, | ||
"requiredLinearHistory": false, | ||
"requiredPullRequestReviews": [ | ||
{ | ||
"dismissStaleReviews": true, | ||
"dismissalRestrictions": [], | ||
"pullRequestBypassers": [], | ||
"requireCodeOwnerReviews": false, | ||
"requireLastPushApproval": false, | ||
"requiredApprovingReviewCount": 1, | ||
"restrictDismissals": false | ||
} | ||
], | ||
"requiredStatusChecks": [] | ||
}, | ||
"news": { | ||
"__defaults": [ | ||
"allowsForcePushes", | ||
"lockBranch", | ||
"requireConversationResolution", | ||
"requireSignedCommits", | ||
"requiredLinearHistory" | ||
], | ||
"allowsDeletions": false, | ||
"allowsForcePushes": false, | ||
"enforceAdmins": true, | ||
"lockBranch": false, | ||
"pattern": "main", | ||
"repositoryId": "debug-pulumi-github", | ||
"requireConversationResolution": false, | ||
"requireSignedCommits": false, | ||
"requiredLinearHistory": false, | ||
"requiredPullRequestReviews": [ | ||
{ | ||
"__defaults": [ | ||
"requireLastPushApproval" | ||
], | ||
"dismissStaleReviews": true, | ||
"requireLastPushApproval": false, | ||
"requiredApprovingReviewCount": 1 | ||
} | ||
], | ||
"restrictPushes": [ | ||
{ | ||
"__defaults": [ | ||
"blocksCreations" | ||
], | ||
"blocksCreations": true, | ||
"pushAllowances": [ | ||
"/iwahbe" | ||
] | ||
} | ||
] | ||
}, | ||
"oldInputs": { | ||
"__defaults": [ | ||
"allowsForcePushes", | ||
"blocksCreations", | ||
"lockBranch", | ||
"requireConversationResolution", | ||
"requireSignedCommits", | ||
"requiredLinearHistory" | ||
], | ||
"allowsDeletions": false, | ||
"allowsForcePushes": false, | ||
"blocksCreations": false, | ||
"enforceAdmins": true, | ||
"lockBranch": false, | ||
"pattern": "main", | ||
"pushRestrictions": [ | ||
"/iwahbe" | ||
], | ||
"repositoryId": "debug-pulumi-github", | ||
"requireConversationResolution": false, | ||
"requireSignedCommits": false, | ||
"requiredLinearHistory": false, | ||
"requiredPullRequestReviews": [ | ||
{ | ||
"__defaults": [ | ||
"requireLastPushApproval" | ||
], | ||
"dismissStaleReviews": true, | ||
"requireLastPushApproval": false, | ||
"requiredApprovingReviewCount": 1 | ||
} | ||
] | ||
} | ||
}, | ||
"response": { | ||
"replaces": [ | ||
"repositoryId" | ||
], | ||
"changes": "DIFF_SOME", | ||
"diffs": "*", | ||
"detailedDiff": { | ||
"allowsDeletions": { | ||
"kind": "UPDATE" | ||
}, | ||
"allowsForcePushes": { | ||
"kind": "UPDATE" | ||
}, | ||
"enforceAdmins": { | ||
"kind": "UPDATE" | ||
}, | ||
"lockBranch": { | ||
"kind": "UPDATE" | ||
}, | ||
"pattern": { | ||
"kind": "UPDATE" | ||
}, | ||
"repositoryId": { | ||
"kind": "UPDATE_REPLACE" | ||
}, | ||
"requireConversationResolution": { | ||
"kind": "UPDATE" | ||
}, | ||
"requireSignedCommits": { | ||
"kind": "UPDATE" | ||
}, | ||
"requiredLinearHistory": { | ||
"kind": "UPDATE" | ||
}, | ||
"requiredPullRequestReviews[0].dismissStaleReviews": { | ||
"kind": "UPDATE" | ||
}, | ||
"requiredPullRequestReviews[0].requireLastPushApproval": { | ||
"kind": "UPDATE" | ||
}, | ||
"requiredPullRequestReviews[0].requiredApprovingReviewCount": { | ||
"kind": "UPDATE" | ||
}, | ||
"restrictPushes[0].blocksCreations": {}, | ||
"restrictPushes[0].pushAllowances[0]": {} | ||
}, | ||
"hasDetailedDiff": true | ||
}, | ||
"metadata": { | ||
"kind": "resource", | ||
"mode": "client", | ||
"name": "github" | ||
} | ||
} | ||
] | ||
` | ||
|
||
func TestRepros(t *testing.T) { | ||
t.Run("586", func(t *testing.T) { | ||
replay.ReplaySequence(t, server(t), repro586) | ||
}) | ||
} | ||
|
||
func init() { | ||
version.Version = "6.0.0" | ||
} | ||
|
||
func server(*testing.T) pulumirpc.ResourceProviderServer { | ||
p := github.Provider() | ||
return tfbridge.NewProvider(context.Background(), | ||
nil, "github", version.Version, p.P, p, []byte("{}")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters