Skip to content

Commit bf12956

Browse files
committed
Fix order of params for updateVulnerabilityAlerts
Signed-off-by: Timo Sand <[email protected]>
1 parent 0e281d0 commit bf12956

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

github/resource_github_repository.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ func resourceGithubRepositoryCreate(ctx context.Context, d *schema.ResourceData,
792792
}
793793
}
794794

795-
err := updateVulnerabilityAlerts(d, client, ctx, owner, repoName)
795+
err := updateVulnerabilityAlerts(ctx, d, client, owner, repoName)
796796
if err != nil {
797797
return diag.FromErr(err)
798798
}
@@ -1040,7 +1040,7 @@ func resourceGithubRepositoryUpdate(ctx context.Context, d *schema.ResourceData,
10401040
}
10411041

10421042
if d.HasChange("vulnerability_alerts") {
1043-
err = updateVulnerabilityAlerts(d, client, ctx, owner, repoName)
1043+
err = updateVulnerabilityAlerts(ctx, d, client, owner, repoName)
10441044
if err != nil {
10451045
return diag.FromErr(err)
10461046
}
@@ -1266,7 +1266,7 @@ func resourceGithubParseFullName(resourceDataLike interface {
12661266
return parts[0], parts[1], true
12671267
}
12681268

1269-
func updateVulnerabilityAlerts(d *schema.ResourceData, client *github.Client, ctx context.Context, owner, repoName string) error {
1269+
func updateVulnerabilityAlerts(ctx context.Context, d *schema.ResourceData, client *github.Client, owner, repoName string) error {
12701270
updateVulnerabilityAlertsSDK := client.Repositories.DisableVulnerabilityAlerts
12711271
vulnerabilityAlerts, ok := d.GetOk("vulnerability_alerts")
12721272

@@ -1277,7 +1277,14 @@ func updateVulnerabilityAlerts(d *schema.ResourceData, client *github.Client, ct
12771277
}
12781278

12791279
resp, err := updateVulnerabilityAlertsSDK(ctx, owner, repoName)
1280-
if err != nil {
1280+
if err != nil && resp != nil {
1281+
tflog.Debug(ctx, "Error updating vulnerability alerts", map[string]any{
1282+
"owner": owner,
1283+
"repository": repoName,
1284+
"error": err.Error(),
1285+
"status_code": resp.StatusCode,
1286+
"body": resp.Body,
1287+
})
12811288
// Check if the error is because an Organization or Enterprise policy is preventing the change
12821289
// This is a temporary workaround while we extract Vulnerability Alerts into a separate resource.
12831290
if resp.StatusCode == http.StatusUnprocessableEntity && strings.Contains(err.Error(), "An enforced security configuration prevented modifying") && !ok {

0 commit comments

Comments
 (0)