Skip to content

Commit 50f95cd

Browse files
committed
Updates the logic to remove duplicate contionals and simplify
1 parent 67001eb commit 50f95cd

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

github/resource_github_actions_environment_variable.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,11 @@ func resourceGithubActionsEnvironmentVariableCreateOrUpdate(d *schema.ResourceDa
7878
_, err := client.Actions.CreateEnvVariable(ctx, owner, repoName, escapedEnvName, variable)
7979
if err != nil {
8080
ghErr := &github.ErrorResponse{}
81-
if errors.As(err, &ghErr) {
82-
if ghErr.Response.StatusCode == http.StatusConflict {
83-
// Variable already exists, try to update instead
84-
_, err = client.Actions.UpdateEnvVariable(ctx, owner, repoName, escapedEnvName, variable)
85-
if err != nil {
86-
return err
87-
}
88-
} else {
81+
if errors.As(err, &ghErr) && ghErr.Response.StatusCode == http.StatusConflict {
82+
// Variable already exists, try to update instead
83+
// If it fails here, we want to return the error otherwise continue
84+
_, err = client.Actions.UpdateEnvVariable(ctx, owner, repoName, escapedEnvName, variable)
85+
if err != nil {
8986
return err
9087
}
9188
} else {

0 commit comments

Comments
 (0)