Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions github/resource_github_actions_environment_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,11 @@ func resourceGithubActionsEnvironmentVariableCreateOrUpdate(d *schema.ResourceDa
_, err := client.Actions.CreateEnvVariable(ctx, owner, repoName, escapedEnvName, variable)
if err != nil {
ghErr := &github.ErrorResponse{}
if errors.As(err, &ghErr) {
if ghErr.Response.StatusCode == http.StatusConflict {
// Variable already exists, try to update instead
_, err = client.Actions.UpdateEnvVariable(ctx, owner, repoName, escapedEnvName, variable)
if err != nil {
return err
}
} else {
if errors.As(err, &ghErr) && ghErr.Response.StatusCode == http.StatusConflict {
// Variable already exists, try to update instead
// If it fails here, we want to return the error otherwise continue
_, err = client.Actions.UpdateEnvVariable(ctx, owner, repoName, escapedEnvName, variable)
if err != nil {
return err
}
} else {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: it looks like the else might be redundant here or are there legitimate use-case where it's fine to swallow err?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is. When create fails but update succeeds.

Expand Down
1 change: 1 addition & 0 deletions github/resource_github_user_ssh_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func resourceGithubUserSshKeyRead(d *schema.ResourceData, meta any) error {
return nil
}
}
return err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only one that doesn't return a redundant error on this PR, I think. But I would still remove the return err above.

}

if err = d.Set("etag", resp.Header.Get("ETag")); err != nil {
Expand Down