Skip to content

Commit

Permalink
restore read_error (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
rucciva committed Nov 8, 2020
1 parent b9e50f1 commit 4fe5080
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions linux/script-resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,21 @@ func (h handlerScriptResource) read(ctx context.Context, rd *schema.ResourceData
func (h handlerScriptResource) Read(ctx context.Context, rd *schema.ResourceData, meta interface{}) (d diag.Diagnostics) {
old := cast.ToString(rd.Get(attrScriptOutput))

err := h.read(ctx, rd, meta.(*linux))
var errExit *remote.ExitError
switch err := h.read(ctx, rd, meta.(*linux)); {
switch {
case errors.As(err, &errExit):
_ = rd.Set(attrScriptReadFailed, true)
_ = rd.Set(attrScriptReadError, err.Error())
return
case err != nil:

default:
_ = rd.Set(attrScriptReadFailed, false)
_ = rd.Set(attrScriptReadError, "")
}
if err != nil {
return diag.FromErr(err)
}
_ = rd.Set(attrScriptReadFailed, false)

new := cast.ToString(rd.Get(attrScriptOutput))
if err := rd.Set(attrScriptDirty, old != new); err != nil {
Expand Down

0 comments on commit 4fe5080

Please sign in to comment.