Skip to content

Commit a49c91c

Browse files
committed
fix: remove unnecessary resp nil guards in runner group Read/Update
The response is always non-nil on the success path — if the API call errors we return early, and even the 304 Not Modified path returns a valid response object. The fallback to the stored ETag was unreachable.
1 parent 03c3c25 commit a49c91c

2 files changed

Lines changed: 4 additions & 16 deletions

File tree

github/resource_github_actions_runner_group.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,7 @@ func resourceGithubActionsRunnerGroupRead(ctx context.Context, d *schema.Resourc
265265
return diag.FromErr(err)
266266
}
267267

268-
runnerGroupEtag := normalizeEtag(d.Get("etag").(string))
269-
if resp != nil {
270-
runnerGroupEtag = normalizeEtag(resp.Header.Get("ETag"))
271-
}
268+
runnerGroupEtag := normalizeEtag(resp.Header.Get("ETag"))
272269

273270
runnerGroupNetworking, _, err := getRunnerGroupNetworking(client, ctx, fmt.Sprintf("orgs/%s/actions/runner-groups/%d", orgName, runnerGroupID))
274271
if err != nil {
@@ -390,10 +387,7 @@ func resourceGithubActionsRunnerGroupUpdate(ctx context.Context, d *schema.Resou
390387
return diag.FromErr(err)
391388
}
392389

393-
runnerGroupEtag := normalizeEtag(d.Get("etag").(string))
394-
if resp != nil {
395-
runnerGroupEtag = normalizeEtag(resp.Header.Get("ETag"))
396-
}
390+
runnerGroupEtag := normalizeEtag(resp.Header.Get("ETag"))
397391

398392
if err := setGithubActionsRunnerGroupState(d, runnerGroup, runnerGroupEtag, selectedRepositoryIDs); err != nil {
399393
return diag.FromErr(err)

github/resource_github_enterprise_actions_runner_group.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,7 @@ func resourceGithubActionsEnterpriseRunnerGroupRead(ctx context.Context, d *sche
251251
return diag.FromErr(err)
252252
}
253253

254-
runnerGroupEtag := normalizeEtag(d.Get("etag").(string))
255-
if resp != nil {
256-
runnerGroupEtag = normalizeEtag(resp.Header.Get("ETag"))
257-
}
254+
runnerGroupEtag := normalizeEtag(resp.Header.Get("ETag"))
258255

259256
runnerGroupNetworking, _, err := getRunnerGroupNetworking(client, ctx, fmt.Sprintf("enterprises/%s/actions/runner-groups/%d", enterpriseSlug, runnerGroupID))
260257
if err != nil {
@@ -373,10 +370,7 @@ func resourceGithubActionsEnterpriseRunnerGroupUpdate(ctx context.Context, d *sc
373370
return diag.FromErr(err)
374371
}
375372

376-
runnerGroupEtag := normalizeEtag(d.Get("etag").(string))
377-
if resp != nil {
378-
runnerGroupEtag = normalizeEtag(resp.Header.Get("ETag"))
379-
}
373+
runnerGroupEtag := normalizeEtag(resp.Header.Get("ETag"))
380374

381375
if err := setGithubActionsEnterpriseRunnerGroupState(d, runnerGroup, runnerGroupEtag, enterpriseSlug, selectedOrganizationIDs); err != nil {
382376
return diag.FromErr(err)

0 commit comments

Comments
 (0)