Skip to content

Commit

Permalink
update error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
abuxton committed Nov 25, 2021
1 parent 5983e66 commit 064e5f2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/tfvar/tfvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ func WriteAsTFVars(w io.Writer, vars []Variable) error {
return errors.Wrap(err, "tfvar: failed to write as tfvars")
}
func WriteAsWorkspacePayload(w io.Writer, vars []Variable) error {
var payload error

var data error
for _, v := range vars {
val := convertNull(v.Value)

Expand All @@ -140,13 +139,12 @@ func WriteAsWorkspacePayload(w io.Writer, vars []Variable) error {
}
}
`, v.Name, string(b), v.Description, "terraform", "false", v.Sensitive)
if payload == nil {
_, err := fmt.Fprintf(w, "%s", data)
payload = errors.Wrap(err, "tfvar: unexpected error writing payload")
if _, err := fmt.Fprintf(w, "%s", data); err != nil {
return errors.Wrap(err, "tfvar: unexpected error writing payload")
}
}

return payload
}
return data
}
func WriteAsTFE_Resource(w io.Writer, vars []Variable) error {
f := hclwrite.NewEmptyFile()
Expand Down

0 comments on commit 064e5f2

Please sign in to comment.