Skip to content

Commit

Permalink
fix(provider): id computation is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaLohinski committed Feb 26, 2024
1 parent 15d50d7 commit 1d8c43d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/provider/data_source_jinja_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provider
import (
"context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"os"
Expand Down Expand Up @@ -242,7 +243,15 @@ func (t *TemplateDataSource) Read(ctx context.Context, req datasource.ReadReques
return
}
data.Result = types.StringValue(string(result))
data.ID = types.StringValue(string(sha256.New().Sum(result)))
signature := sha256.New()
if _, err := signature.Write(result); err != nil {
resp.Diagnostics.AddError(
"Failed to compute ID from result",
fmt.Sprintf("trying to compute sha256 of the rendering result failed: %s", err.Error()),
)
return
}
data.ID = types.StringValue(hex.EncodeToString(signature.Sum(nil)))

merged_context, err := json.Marshal(values)
if err != nil {
Expand Down

0 comments on commit 1d8c43d

Please sign in to comment.