From da70c732447fd3f44a9de256fbdd53158a39ae12 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Wed, 18 Dec 2024 14:51:58 -0800 Subject: [PATCH 1/3] Ensure create/update funcs return early if errored --- pkg/project/resource/resource_project_environment.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/project/resource/resource_project_environment.go b/pkg/project/resource/resource_project_environment.go index f0f47546..1db23b07 100644 --- a/pkg/project/resource/resource_project_environment.go +++ b/pkg/project/resource/resource_project_environment.go @@ -3,7 +3,6 @@ package project import ( "context" "fmt" - "net/http" "regexp" "strings" @@ -114,9 +113,11 @@ func (r *ProjectEnvironmentResource) Create(ctx context.Context, req resource.Cr Post(ProjectEnvironmentUrl) if err != nil { utilfw.UnableToCreateResourceError(resp, err.Error()) + return } if response.IsError() { utilfw.UnableToCreateResourceError(resp, projectError.String()) + return } plan.ID = types.StringValue(environment.Name) @@ -148,10 +149,6 @@ func (r *ProjectEnvironmentResource) Read(ctx context.Context, req resource.Read utilfw.UnableToRefreshResourceError(resp, err.Error()) return } - if response.StatusCode() == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } if response.IsError() { utilfw.UnableToRefreshResourceError(resp, projectError.String()) return @@ -211,9 +208,11 @@ func (r *ProjectEnvironmentResource) Update(ctx context.Context, req resource.Up Post(ProjectEnvironmentUrl + "/{environmentName}/rename") if err != nil { utilfw.UnableToUpdateResourceError(resp, err.Error()) + return } if response.IsError() { utilfw.UnableToUpdateResourceError(resp, projectError.String()) + return } plan.ID = types.StringValue(environmentUpdate.NewName) From 67ba44b4708d09e7f999ea42afe0b4eb94230daf Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Wed, 18 Dec 2024 15:06:04 -0800 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9de1c430..210d2a4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.9.3 (December 19, 2024) + +BUG FIXES: + +* resource/project_environment: Fix error handling during creation/update where state shouldn't be stored/updated when there is API error. Issue: [#184](https://github.com/jfrog/terraform-provider-project/issues/184) PR: [#188](https://github.com/jfrog/terraform-provider-project/pull/188) + ## 1.9.2 (November 26, 2024). Tested on Artifactory 7.98.9 with Terraform 1.9.8 and OpenTofu 1.8.6 IMPROVEMENTS: From b288eb13eefac5593da4f90df3996ffd7c9b19de Mon Sep 17 00:00:00 2001 From: JFrog CI Date: Wed, 18 Dec 2024 23:12:48 +0000 Subject: [PATCH 3/3] JFrog Pipelines - Add Artifactory version to CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 210d2a4a..0423b9c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.9.3 (December 19, 2024) +## 1.9.3 (December 19, 2024). Tested on Artifactory 7.98.11 with Terraform 1.10.3 and OpenTofu 1.8.7 BUG FIXES: