-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uplift branch_protection resource to use v4 API
- Loading branch information
1 parent
60fff96
commit 8430e4b
Showing
6 changed files
with
518 additions
and
532 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,40 @@ | ||
package github | ||
|
||
import "github.com/hashicorp/terraform/helper/schema" | ||
|
||
func resourceGithubBranchProtectionV0() *schema.Resource { | ||
return &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"repository": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
"branch": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func resourceGithubBranchProtectionUpgradeV0(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { | ||
repoName := rawState["repository"].(string) | ||
repoID, err := getRepositoryID(repoName, meta) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
branch := rawState["branch"].(string) | ||
protectionRuleID, err := getBranchProtectionID(repoName, branch, meta) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
rawState[id] = protectionRuleID | ||
rawState[repositoryID] = repoID | ||
rawState[pattern] = branch | ||
|
||
return rawState, nil | ||
} |
Oops, something went wrong.