Skip to content

Commit

Permalink
reverted incorrect change to missing resource handling
Browse files Browse the repository at this point in the history
  • Loading branch information
benPearce1 committed Nov 22, 2024
1 parent b2eb8d6 commit c761241
Show file tree
Hide file tree
Showing 32 changed files with 41 additions and 45 deletions.
10 changes: 5 additions & 5 deletions internal/errors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 {

Check warning on line 41 in internal/errors/error.go

View workflow job for this annotation

GitHub Actions / build

func ProcessApiErrorV2 should be ProcessAPIErrorV2
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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 6 additions & 10 deletions octopusdeploy_framework/resource_deploymentfreeze.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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())
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_git_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_github_repository_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_helm_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_library_variable_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_machine_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_maven_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_nuget_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_oci_registry_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_project_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_runbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_s3_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_script_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_ssh_connection_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_step_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_tag_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c761241

Please sign in to comment.