Skip to content

Commit

Permalink
fixed repository environments so terraform will readd back in deploym…
Browse files Browse the repository at this point in the history
…ent branch protection if it is removed manually from GitHub (#1981)

Co-authored-by: Keegan Campbell <me@kfcampbell.com>
  • Loading branch information
scott-doyland-burrows and kfcampbell committed Oct 26, 2023
1 parent 5aa1d77 commit f85bfb8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion github/resource_github_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func resourceGithubBranchImport(d *schema.ResourceData, meta interface{}) ([]*sc

// resourceGithubBranchRead calls d.SetId("") if the branch does not exist
if d.Id() == "" {
return nil, fmt.Errorf("repository %s does not have a branch named %s.", repoName, branchName)
return nil, fmt.Errorf("repository %s does not have a branch named %s", repoName, branchName)
}

return []*schema.ResourceData{d}, nil
Expand Down
2 changes: 1 addition & 1 deletion github/resource_github_branch_protection_v3_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func expandRequiredStatusChecks(d *schema.ResourceData) (*github.RequiredStatusC
// If we have a valid app_id, include it in the RSC
rscAppId, err := strconv.Atoi(cAppId)
if err != nil {
return nil, fmt.Errorf("Could not parse %v as valid app_id", cAppId)
return nil, fmt.Errorf("could not parse %v as valid app_id", cAppId)
}
rscAppId64 := int64(rscAppId)
rscCheck = &github.RequiredStatusCheck{Context: cContext, AppID: &rscAppId64}
Expand Down
2 changes: 2 additions & 0 deletions github/resource_github_repository_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ func resourceGithubRepositoryEnvironmentRead(d *schema.ResourceData, meta interf
"custom_branch_policies": env.DeploymentBranchPolicy.CustomBranchPolicies,
},
})
} else {
d.Set("deployment_branch_policy", []interface{}{})
}

return nil
Expand Down

0 comments on commit f85bfb8

Please sign in to comment.