Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
hsafra committed Aug 27, 2024
1 parent d68ea6a commit b61ca12
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion api/file_api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
This file has api functions for working with the data file structure we define.
The file has two primitives: ReadLine and WriteLine
*/

package api
Expand Down
7 changes: 6 additions & 1 deletion internal/provider/file_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-log/tflog"
"regexp"
"strconv"
"strings"
"terraform-provider-filedata/api"
)

Expand Down Expand Up @@ -131,7 +132,11 @@ func (r *File) Read(ctx context.Context, req resource.ReadRequest, resp *resourc

lineCount, err := api.LineCount(fullName)
if err != nil {
resp.Diagnostics.AddError("Read Error", fmt.Sprintf("Unable to read file, got error: %s", err))
if strings.HasSuffix(err.Error(), "no such file or directory") {
resp.State.RemoveResource(ctx)
} else {
resp.Diagnostics.AddError("Read Error", fmt.Sprintf("Unable to read file, got error: %s", err))
}
return
}

Expand Down
2 changes: 1 addition & 1 deletion tests/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
filedata = {
source = "hsafra/filedata"
source = "hsafra/filedata"
}
}
required_version = ">= 1.0.6"
Expand Down

0 comments on commit b61ca12

Please sign in to comment.