From c761241e211540037fefb02061a0dae2ae96a751 Mon Sep 17 00:00:00 2001 From: Ben Pearce Date: Fri, 22 Nov 2024 10:28:11 +1000 Subject: [PATCH] reverted incorrect change to missing resource handling --- internal/errors/error.go | 10 +++++----- .../resource_artifactory_generic_feed.go | 2 +- .../resource_aws_elastic_container_registry.go | 2 +- .../resource_azure_container_registry.go | 2 +- .../resource_deploymentfreeze.go | 16 ++++++---------- .../resource_docker_container_registry.go | 2 +- octopusdeploy_framework/resource_environment.go | 2 +- .../resource_git_credential.go | 2 +- .../resource_github_repository_feed.go | 2 +- .../resource_google_container_registry.go | 2 +- octopusdeploy_framework/resource_helm_feed.go | 2 +- .../resource_library_variable_set.go | 2 +- octopusdeploy_framework/resource_lifecycle.go | 2 +- .../resource_listening_tentacle_worker.go | 2 +- .../resource_machine_proxy.go | 2 +- octopusdeploy_framework/resource_maven_feed.go | 2 +- octopusdeploy_framework/resource_nuget_feed.go | 2 +- .../resource_oci_registry_feed.go | 2 +- octopusdeploy_framework/resource_project.go | 2 +- .../resource_project_group.go | 2 +- octopusdeploy_framework/resource_runbook.go | 2 +- octopusdeploy_framework/resource_s3_feed.go | 2 +- .../resource_script_module.go | 2 +- .../resource_service_account_oidc_identity.go | 2 +- octopusdeploy_framework/resource_space.go | 2 +- .../resource_ssh_connection_worker.go | 2 +- .../resource_step_template.go | 2 +- octopusdeploy_framework/resource_tag_set.go | 2 +- octopusdeploy_framework/resource_tenant.go | 2 +- octopusdeploy_framework/resource_user.go | 2 +- .../resource_username_password_account.go | 2 +- octopusdeploy_framework/resource_variable.go | 2 +- 32 files changed, 41 insertions(+), 45 deletions(-) diff --git a/internal/errors/error.go b/internal/errors/error.go index 203f49486..ecd9d1076 100644 --- a/internal/errors/error.go +++ b/internal/errors/error.go @@ -2,7 +2,7 @@ package errors import ( "context" - "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/resource" "log" "net/http" @@ -32,20 +32,20 @@ func ProcessApiError(ctx context.Context, d *schema.ResourceData, err error, res return diag.FromErr(err) } -func DeleteFromStateV2(ctx context.Context, state *tfsdk.State, resource schemas.IResourceModel, resourceDescription string) error { +func DeleteFromStateV2(ctx context.Context, resp *resource.ReadResponse, resource schemas.IResourceModel, resourceDescription string) error { log.Printf("[INFO] %s (%s) not found; deleting from state", resourceDescription, resource.GetID()) - state.RemoveResource(ctx) + resp.State.RemoveResource(ctx) return nil } -func ProcessApiErrorV2(ctx context.Context, state *tfsdk.State, resource schemas.IResourceModel, err error, resourceDescription string) error { +func ProcessApiErrorV2(ctx context.Context, resp *resource.ReadResponse, resource schemas.IResourceModel, err error, resourceDescription string) error { if err == nil { return nil } if apiError, ok := err.(*core.APIError); ok { if apiError.StatusCode == http.StatusNotFound { - return DeleteFromStateV2(ctx, state, resource, resourceDescription) + return DeleteFromStateV2(ctx, resp, resource, resourceDescription) } } diff --git a/octopusdeploy_framework/resource_artifactory_generic_feed.go b/octopusdeploy_framework/resource_artifactory_generic_feed.go index ecfb28941..28fd95963 100644 --- a/octopusdeploy_framework/resource_artifactory_generic_feed.go +++ b/octopusdeploy_framework/resource_artifactory_generic_feed.go @@ -78,7 +78,7 @@ func (r *artifactoryGenericFeedTypeResource) Read(ctx context.Context, req resou client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "artifactory generic feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "artifactory generic feed"); err != nil { resp.Diagnostics.AddError("unable to load artifactoryGeneric feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_aws_elastic_container_registry.go b/octopusdeploy_framework/resource_aws_elastic_container_registry.go index 842e9a0a6..dae213ec9 100644 --- a/octopusdeploy_framework/resource_aws_elastic_container_registry.go +++ b/octopusdeploy_framework/resource_aws_elastic_container_registry.go @@ -79,7 +79,7 @@ func (r *awsElasticContainerRegistryFeedTypeResource) Read(ctx context.Context, client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "aws elastic container registry"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "aws elastic container registry"); err != nil { resp.Diagnostics.AddError("unable to load aws elastic container registry", err.Error()) } return diff --git a/octopusdeploy_framework/resource_azure_container_registry.go b/octopusdeploy_framework/resource_azure_container_registry.go index 2557f0d1a..0430a10af 100644 --- a/octopusdeploy_framework/resource_azure_container_registry.go +++ b/octopusdeploy_framework/resource_azure_container_registry.go @@ -76,7 +76,7 @@ func (r *azureContainerRegistryFeedTypeResource) Read(ctx context.Context, req r client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "azure container registry feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "azure container registry feed"); err != nil { resp.Diagnostics.AddError("unable to load Azure Container Registry feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_deploymentfreeze.go b/octopusdeploy_framework/resource_deploymentfreeze.go index 2952009c8..b88c478f7 100644 --- a/octopusdeploy_framework/resource_deploymentfreeze.go +++ b/octopusdeploy_framework/resource_deploymentfreeze.go @@ -52,7 +52,7 @@ func (f *deploymentFreezeResource) Read(ctx context.Context, req resource.ReadRe deploymentFreeze, err := deploymentfreezes.GetById(f.Config.Client, state.GetID()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, state, err, "deployment freeze"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, state, err, "deployment freeze"); err != nil { resp.Diagnostics.AddError("unable to load deployment freeze", err.Error()) } return @@ -76,7 +76,7 @@ func (f *deploymentFreezeResource) Create(ctx context.Context, req resource.Crea } var deploymentFreeze *deploymentfreezes.DeploymentFreeze - deploymentFreeze, err := mapFromState(ctx, plan) + deploymentFreeze, err := mapFromState(plan) if err != nil { resp.Diagnostics.AddError("error while creating deployment freeze", err.Error()) return @@ -106,13 +106,11 @@ func (f *deploymentFreezeResource) Update(ctx context.Context, req resource.Upda existingFreeze, err := deploymentfreezes.GetById(f.Config.Client, plan.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, plan, err, "deployment freeze"); err != nil { - resp.Diagnostics.AddError("unable to load deployment freeze", err.Error()) - } + resp.Diagnostics.AddError("unable to load deployment freeze", err.Error()) return } - updatedFreeze, err := mapFromState(ctx, plan) + updatedFreeze, err := mapFromState(plan) if err != nil { resp.Diagnostics.AddError("error while mapping deployment freeze", err.Error()) } @@ -143,9 +141,7 @@ func (f *deploymentFreezeResource) Delete(ctx context.Context, req resource.Dele freeze, err := deploymentfreezes.GetById(f.Config.Client, state.GetID()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, state, err, "deployment freeze"); err != nil { - resp.Diagnostics.AddError("unable to load deployment freeze", err.Error()) - } + resp.Diagnostics.AddError("unable to load deployment freeze", err.Error()) return } @@ -176,7 +172,7 @@ func mapToState(ctx context.Context, state *deploymentFreezeModel, deploymentFre return nil } -func mapFromState(ctx context.Context, state *deploymentFreezeModel) (*deploymentfreezes.DeploymentFreeze, error) { +func mapFromState(state *deploymentFreezeModel) (*deploymentfreezes.DeploymentFreeze, error) { start, err := time.Parse(time.RFC3339, state.Start.ValueString()) if err != nil { return nil, err diff --git a/octopusdeploy_framework/resource_docker_container_registry.go b/octopusdeploy_framework/resource_docker_container_registry.go index 689e7033e..c43208478 100644 --- a/octopusdeploy_framework/resource_docker_container_registry.go +++ b/octopusdeploy_framework/resource_docker_container_registry.go @@ -77,7 +77,7 @@ func (r *dockerContainerRegistryFeedTypeResource) Read(ctx context.Context, req client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "docker container registry feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "docker container registry feed"); err != nil { resp.Diagnostics.AddError("unable to load docker container registry feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_environment.go b/octopusdeploy_framework/resource_environment.go index e3c7507d4..779841fec 100644 --- a/octopusdeploy_framework/resource_environment.go +++ b/octopusdeploy_framework/resource_environment.go @@ -90,7 +90,7 @@ func (r *environmentTypeResource) Read(ctx context.Context, req resource.ReadReq environment, err := environments.GetByID(r.Config.Client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "environment"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "environment"); err != nil { resp.Diagnostics.AddError("unable to load environment", err.Error()) } return diff --git a/octopusdeploy_framework/resource_git_credential.go b/octopusdeploy_framework/resource_git_credential.go index 6eb57b932..197776069 100644 --- a/octopusdeploy_framework/resource_git_credential.go +++ b/octopusdeploy_framework/resource_git_credential.go @@ -95,7 +95,7 @@ func (g *gitCredentialResource) Read(ctx context.Context, req resource.ReadReque gitCredential, err := credentials.GetByID(g.Client, state.SpaceID.ValueString(), state.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, state, err, "git credential"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, state, err, "git credential"); err != nil { resp.Diagnostics.AddError("Error reading Git credential", err.Error()) } return diff --git a/octopusdeploy_framework/resource_github_repository_feed.go b/octopusdeploy_framework/resource_github_repository_feed.go index d1363b0c1..8d1743092 100644 --- a/octopusdeploy_framework/resource_github_repository_feed.go +++ b/octopusdeploy_framework/resource_github_repository_feed.go @@ -79,7 +79,7 @@ func (r *githubRepositoryFeedTypeResource) Read(ctx context.Context, req resourc client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "github repository feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "github repository feed"); err != nil { resp.Diagnostics.AddError("unable to load github repository feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_google_container_registry.go b/octopusdeploy_framework/resource_google_container_registry.go index afc015129..e9bb299aa 100644 --- a/octopusdeploy_framework/resource_google_container_registry.go +++ b/octopusdeploy_framework/resource_google_container_registry.go @@ -76,7 +76,7 @@ func (r *googleContainerRegistryFeedTypeResource) Read(ctx context.Context, req client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "google container registry feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "google container registry feed"); err != nil { resp.Diagnostics.AddError("unable to load Google Container Registry feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_helm_feed.go b/octopusdeploy_framework/resource_helm_feed.go index 8f19b2400..9276d9273 100644 --- a/octopusdeploy_framework/resource_helm_feed.go +++ b/octopusdeploy_framework/resource_helm_feed.go @@ -78,7 +78,7 @@ func (r *helmFeedTypeResource) Read(ctx context.Context, req resource.ReadReques client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "helm feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "helm feed"); err != nil { resp.Diagnostics.AddError("unable to load helm feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_library_variable_set.go b/octopusdeploy_framework/resource_library_variable_set.go index 6bbf41cb9..d32f052fb 100644 --- a/octopusdeploy_framework/resource_library_variable_set.go +++ b/octopusdeploy_framework/resource_library_variable_set.go @@ -66,7 +66,7 @@ func (r *libraryVariableSetFeedTypeResource) Read(ctx context.Context, req resou libraryVariableSet, err := libraryvariablesets.GetByID(r.Config.Client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "library variable set"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "library variable set"); err != nil { resp.Diagnostics.AddError("unable to load library variable set", err.Error()) } return diff --git a/octopusdeploy_framework/resource_lifecycle.go b/octopusdeploy_framework/resource_lifecycle.go index 83c5eafa4..3ab549f0a 100644 --- a/octopusdeploy_framework/resource_lifecycle.go +++ b/octopusdeploy_framework/resource_lifecycle.go @@ -91,7 +91,7 @@ func (r *lifecycleTypeResource) Read(ctx context.Context, req resource.ReadReque lifecycle, err := lifecycles.GetByID(r.Config.Client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "lifecycle"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "lifecycle"); err != nil { resp.Diagnostics.AddError("unable to load lifecycle", err.Error()) } return diff --git a/octopusdeploy_framework/resource_listening_tentacle_worker.go b/octopusdeploy_framework/resource_listening_tentacle_worker.go index 181c5091e..0663656ae 100644 --- a/octopusdeploy_framework/resource_listening_tentacle_worker.go +++ b/octopusdeploy_framework/resource_listening_tentacle_worker.go @@ -74,7 +74,7 @@ func (r *listeningTentacleWorkerResource) Read(ctx context.Context, req resource client := r.Config.Client worker, err := workers.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "listening tentacle worker"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "listening tentacle worker"); err != nil { resp.Diagnostics.AddError("unable to load listening tentacle worker", err.Error()) } return diff --git a/octopusdeploy_framework/resource_machine_proxy.go b/octopusdeploy_framework/resource_machine_proxy.go index 4f7493d23..af8eeea2e 100644 --- a/octopusdeploy_framework/resource_machine_proxy.go +++ b/octopusdeploy_framework/resource_machine_proxy.go @@ -63,7 +63,7 @@ func (r *machineProxyResource) Read(ctx context.Context, req resource.ReadReques machineProxy, err := proxies.GetByID(r.Client, state.SpaceID.ValueString(), state.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, state, err, "machine proxy"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, state, err, "machine proxy"); err != nil { resp.Diagnostics.AddError("Error reading machine proxy", err.Error()) } return diff --git a/octopusdeploy_framework/resource_maven_feed.go b/octopusdeploy_framework/resource_maven_feed.go index 01a15df08..7920d77a3 100644 --- a/octopusdeploy_framework/resource_maven_feed.go +++ b/octopusdeploy_framework/resource_maven_feed.go @@ -77,7 +77,7 @@ func (r *mavenFeedTypeResource) Read(ctx context.Context, req resource.ReadReque client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "maven feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "maven feed"); err != nil { resp.Diagnostics.AddError("unable to load maven feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_nuget_feed.go b/octopusdeploy_framework/resource_nuget_feed.go index d6d881bfe..71229b558 100644 --- a/octopusdeploy_framework/resource_nuget_feed.go +++ b/octopusdeploy_framework/resource_nuget_feed.go @@ -79,7 +79,7 @@ func (r *nugetFeedTypeResource) Read(ctx context.Context, req resource.ReadReque client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "nuget feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "nuget feed"); err != nil { resp.Diagnostics.AddError("unable to load nuget feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_oci_registry_feed.go b/octopusdeploy_framework/resource_oci_registry_feed.go index 2e7467d7e..47edca613 100644 --- a/octopusdeploy_framework/resource_oci_registry_feed.go +++ b/octopusdeploy_framework/resource_oci_registry_feed.go @@ -76,7 +76,7 @@ func (r *ociRegistryFeedTypeResource) Read(ctx context.Context, req resource.Rea client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "OCI Registry feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "OCI Registry feed"); err != nil { resp.Diagnostics.AddError("unable to load OCI Registry feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_project.go b/octopusdeploy_framework/resource_project.go index 9fd328751..692ec1794 100644 --- a/octopusdeploy_framework/resource_project.go +++ b/octopusdeploy_framework/resource_project.go @@ -94,7 +94,7 @@ func (r *projectResource) Read(ctx context.Context, req resource.ReadRequest, re project, err := projects.GetByID(r.Client, state.SpaceID.ValueString(), state.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, state, err, "project"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, state, err, "project"); err != nil { resp.Diagnostics.AddError("Error reading project", err.Error()) } return diff --git a/octopusdeploy_framework/resource_project_group.go b/octopusdeploy_framework/resource_project_group.go index 92045003b..d3f87ddd8 100644 --- a/octopusdeploy_framework/resource_project_group.go +++ b/octopusdeploy_framework/resource_project_group.go @@ -65,7 +65,7 @@ func (r *projectGroupTypeResource) Read(ctx context.Context, req resource.ReadRe group, err := projectgroups.GetByID(r.Config.Client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "project group"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "project group"); err != nil { resp.Diagnostics.AddError("unable to load project group", err.Error()) } return diff --git a/octopusdeploy_framework/resource_runbook.go b/octopusdeploy_framework/resource_runbook.go index f0073204c..c4829f365 100644 --- a/octopusdeploy_framework/resource_runbook.go +++ b/octopusdeploy_framework/resource_runbook.go @@ -93,7 +93,7 @@ func (r *runbookTypeResource) Read(ctx context.Context, req resource.ReadRequest runbook, err := runbooks.GetByID(r.Config.Client, state.SpaceID.ValueString(), state.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, state, err, schemas.RunbookResourceDescription); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, state, err, schemas.RunbookResourceDescription); err != nil { resp.Diagnostics.AddError("failed to load runbook", err.Error()) } return diff --git a/octopusdeploy_framework/resource_s3_feed.go b/octopusdeploy_framework/resource_s3_feed.go index caf04556f..e5935e950 100644 --- a/octopusdeploy_framework/resource_s3_feed.go +++ b/octopusdeploy_framework/resource_s3_feed.go @@ -76,7 +76,7 @@ func (r *s3FeedTypeResource) Read(ctx context.Context, req resource.ReadRequest, client := r.Config.Client feed, err := feeds.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "S3 feed"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "S3 feed"); err != nil { resp.Diagnostics.AddError("unable to load S3 feed", err.Error()) } return diff --git a/octopusdeploy_framework/resource_script_module.go b/octopusdeploy_framework/resource_script_module.go index 58388a450..b98d7b9c0 100644 --- a/octopusdeploy_framework/resource_script_module.go +++ b/octopusdeploy_framework/resource_script_module.go @@ -73,7 +73,7 @@ func (r *scriptModuleTypeResource) Read(ctx context.Context, req resource.ReadRe client := r.Config.Client scriptModule, err := scriptmodules.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "Script Module"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "Script Module"); err != nil { resp.Diagnostics.AddError("unable to load script module", err.Error()) } return diff --git a/octopusdeploy_framework/resource_service_account_oidc_identity.go b/octopusdeploy_framework/resource_service_account_oidc_identity.go index a88c46daf..4370833fd 100644 --- a/octopusdeploy_framework/resource_service_account_oidc_identity.go +++ b/octopusdeploy_framework/resource_service_account_oidc_identity.go @@ -62,7 +62,7 @@ func (s *ServiceAccountOIDCIdentity) Read(ctx context.Context, req resource.Read identityResponse, err := serviceaccounts.GetOIDCIdentityByID(s.Client, state.ServiceAccountID.ValueString(), state.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, state, err, "service account OIDC identity"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, state, err, "service account OIDC identity"); err != nil { resp.Diagnostics.AddError("Error reading service account OIDC identity", err.Error()) } return diff --git a/octopusdeploy_framework/resource_space.go b/octopusdeploy_framework/resource_space.go index ee7ca3e26..d90101a9e 100644 --- a/octopusdeploy_framework/resource_space.go +++ b/octopusdeploy_framework/resource_space.go @@ -126,7 +126,7 @@ func (s *spaceResource) Read(ctx context.Context, req resource.ReadRequest, resp spaceResult, err := spaces.GetByID(s.Client, data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "space"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "space"); err != nil { resp.Diagnostics.AddError("unable to query spaces", err.Error()) } return diff --git a/octopusdeploy_framework/resource_ssh_connection_worker.go b/octopusdeploy_framework/resource_ssh_connection_worker.go index d806a5ae5..eaac2d2fe 100644 --- a/octopusdeploy_framework/resource_ssh_connection_worker.go +++ b/octopusdeploy_framework/resource_ssh_connection_worker.go @@ -72,7 +72,7 @@ func (r *sshConnectionWorkerResource) Read(ctx context.Context, req resource.Rea client := r.Config.Client worker, err := workers.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "SSH connection worker"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "SSH connection worker"); err != nil { resp.Diagnostics.AddError("unable to load SSH connection worker", err.Error()) } return diff --git a/octopusdeploy_framework/resource_step_template.go b/octopusdeploy_framework/resource_step_template.go index dd702fb03..01bf45428 100644 --- a/octopusdeploy_framework/resource_step_template.go +++ b/octopusdeploy_framework/resource_step_template.go @@ -75,7 +75,7 @@ func (r *stepTemplateTypeResource) Read(ctx context.Context, req resource.ReadRe actionTemplate, err := actiontemplates.GetByID(r.Config.Client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "action template"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "action template"); err != nil { resp.Diagnostics.AddError("unable to load environment", err.Error()) } return diff --git a/octopusdeploy_framework/resource_tag_set.go b/octopusdeploy_framework/resource_tag_set.go index 17cd432f5..df5f7d9e2 100644 --- a/octopusdeploy_framework/resource_tag_set.go +++ b/octopusdeploy_framework/resource_tag_set.go @@ -61,7 +61,7 @@ func (r *tagSetResource) Read(ctx context.Context, req resource.ReadRequest, res tagSet, err := tagsets.GetByID(r.Client, state.SpaceID.ValueString(), state.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, state, err, "tagSetResource"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, state, err, "tagSetResource"); err != nil { resp.Diagnostics.AddError("unable to load tag set", err.Error()) } return diff --git a/octopusdeploy_framework/resource_tenant.go b/octopusdeploy_framework/resource_tenant.go index 179992fa6..3fa5c5103 100644 --- a/octopusdeploy_framework/resource_tenant.go +++ b/octopusdeploy_framework/resource_tenant.go @@ -79,7 +79,7 @@ func (r *tenantTypeResource) Read(ctx context.Context, req resource.ReadRequest, client := r.Config.Client tenant, err := tenants.GetByID(client, data.SpaceID.ValueString(), data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "tenant"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "tenant"); err != nil { resp.Diagnostics.AddError("unable to load tenant", err.Error()) } return diff --git a/octopusdeploy_framework/resource_user.go b/octopusdeploy_framework/resource_user.go index 66aff26c1..63e370dc6 100644 --- a/octopusdeploy_framework/resource_user.go +++ b/octopusdeploy_framework/resource_user.go @@ -77,7 +77,7 @@ func (r *userTypeResource) Read(ctx context.Context, req resource.ReadRequest, r user, err := users.GetByID(r.Config.Client, data.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, "user"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, data, err, "user"); err != nil { resp.Diagnostics.AddError("unable to load user", err.Error()) } return diff --git a/octopusdeploy_framework/resource_username_password_account.go b/octopusdeploy_framework/resource_username_password_account.go index 22fb4f982..0a70b2127 100644 --- a/octopusdeploy_framework/resource_username_password_account.go +++ b/octopusdeploy_framework/resource_username_password_account.go @@ -67,7 +67,7 @@ func (r *usernamePasswordAccountResource) Read(ctx context.Context, req resource account, err := accounts.GetByID(r.Client, state.SpaceID.ValueString(), state.ID.ValueString()) if err != nil { - if err := errors.ProcessApiErrorV2(ctx, &resp.State, state, err, "usernamePasswordAccountResource"); err != nil { + if err := errors.ProcessApiErrorV2(ctx, resp, state, err, "usernamePasswordAccountResource"); err != nil { resp.Diagnostics.AddError("unable to load username password account", err.Error()) } return diff --git a/octopusdeploy_framework/resource_variable.go b/octopusdeploy_framework/resource_variable.go index 10c3e0ebe..d28763803 100644 --- a/octopusdeploy_framework/resource_variable.go +++ b/octopusdeploy_framework/resource_variable.go @@ -127,7 +127,7 @@ func (r *variableTypeResource) Read(ctx context.Context, req resource.ReadReques variable, err := variables.GetByID(r.Config.Client, data.SpaceID.ValueString(), variableOwnerID.ValueString(), data.ID.ValueString()) if err != nil { - apiError := errors.ProcessApiErrorV2(ctx, &resp.State, data, err, schemas.VariableResourceDescription) + apiError := errors.ProcessApiErrorV2(ctx, resp, data, err, schemas.VariableResourceDescription) if apiError != nil { resp.Diagnostics.AddError("unable to load variable", apiError.Error()) } else {