From 30c7e82746676e133419596dc671fa36b679d158 Mon Sep 17 00:00:00 2001 From: Leo Antoli <430982+lantoli@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:44:29 +0200 Subject: [PATCH] Remove RemoveResource from Create and Update --- internal/service/encryptionatrest/resource.go | 6 +----- internal/service/project/resource_project.go | 12 ++---------- internal/service/pushbasedlogexport/resource.go | 4 ---- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/internal/service/encryptionatrest/resource.go b/internal/service/encryptionatrest/resource.go index e2599fc51e..80947ea814 100644 --- a/internal/service/encryptionatrest/resource.go +++ b/internal/service/encryptionatrest/resource.go @@ -384,12 +384,8 @@ func (r *encryptionAtRestRS) Update(ctx context.Context, req resource.UpdateRequ return } projectID := encryptionAtRestState.ProjectID.ValueString() - atlasEncryptionAtRest, atlasResp, err := connV2.EncryptionAtRestUsingCustomerKeyManagementApi.GetEncryptionAtRest(context.Background(), projectID).Execute() + atlasEncryptionAtRest, _, err := connV2.EncryptionAtRestUsingCustomerKeyManagementApi.GetEncryptionAtRest(context.Background(), projectID).Execute() if err != nil { - if resp != nil && atlasResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } resp.Diagnostics.AddError("error when getting encryption at rest resource during update", fmt.Sprintf(project.ErrorProjectRead, projectID, err.Error())) return } diff --git a/internal/service/project/resource_project.go b/internal/service/project/resource_project.go index 3d0b9d83b2..4f49d5347d 100644 --- a/internal/service/project/resource_project.go +++ b/internal/service/project/resource_project.go @@ -402,12 +402,8 @@ func (r *projectRS) Create(ctx context.Context, req resource.CreateRequest, resp } projectID := project.GetId() - projectRes, atlasResp, err := connV2.ProjectsApi.GetProject(ctx, projectID).Execute() + projectRes, _, err := connV2.ProjectsApi.GetProject(ctx, projectID).Execute() if err != nil { - if resp != nil && atlasResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } resp.Diagnostics.AddError("error when getting project after create", fmt.Sprintf(ErrorProjectRead, projectID, err.Error())) return } @@ -529,12 +525,8 @@ func (r *projectRS) Update(ctx context.Context, req resource.UpdateRequest, resp return } - projectRes, atlasResp, err := connV2.ProjectsApi.GetProject(ctx, projectID).Execute() + projectRes, _, err := connV2.ProjectsApi.GetProject(ctx, projectID).Execute() if err != nil { - if resp != nil && atlasResp.StatusCode == http.StatusNotFound { - resp.State.RemoveResource(ctx) - return - } resp.Diagnostics.AddError("error when getting project after create", fmt.Sprintf(ErrorProjectRead, projectID, err.Error())) return } diff --git a/internal/service/pushbasedlogexport/resource.go b/internal/service/pushbasedlogexport/resource.go index 27c715625c..890778515b 100644 --- a/internal/service/pushbasedlogexport/resource.go +++ b/internal/service/pushbasedlogexport/resource.go @@ -63,8 +63,6 @@ func (r *pushBasedLogExportRS) Create(ctx context.Context, req resource.CreateRe resp.Diagnostics.AddError("Error when unconfiguring push-based log export configuration", err.Error()) return } - - resp.State.RemoveResource(ctx) return } @@ -83,8 +81,6 @@ func (r *pushBasedLogExportRS) Create(ctx context.Context, req resource.CreateRe resp.Diagnostics.AddError("Error when unconfiguring push-based log export configuration", err.Error()) return } - - resp.State.RemoveResource(ctx) return }