Skip to content

Commit dcb0486

Browse files
authored
Update query complete message to a struct (#37395)
1 parent ac015cb commit dcb0486

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

internal/command/views/hook_json.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,11 @@ func (h *jsonHook) PostListQuery(id terraform.HookResourceIdentity, results plan
263263
json.MessageListResourceFound, result,
264264
)
265265
}
266+
266267
h.view.log.Info(
267268
fmt.Sprintf("%s: List complete", addr.String()),
268269
"type", json.MessageListComplete,
269-
"total", data.LengthInt(),
270+
json.MessageListComplete, json.NewQueryComplete(addr, data.LengthInt()),
270271
)
271272
return terraform.HookActionContinue, nil
272273
}

internal/command/views/json/query.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ type QueryResult struct {
2828
ImportConfig string `json:"import_config,omitempty"`
2929
}
3030

31+
type QueryComplete struct {
32+
Address string `json:"address"`
33+
ResourceType string `json:"resource_type"`
34+
Total int `json:"total"`
35+
}
36+
3137
func NewQueryStart(addr addrs.AbsResourceInstance, input_config cty.Value) QueryStart {
3238
return QueryStart{
3339
Address: addr.String(),
@@ -54,6 +60,14 @@ func NewQueryResult(listAddr addrs.AbsResourceInstance, value cty.Value, generat
5460
return result
5561
}
5662

63+
func NewQueryComplete(addr addrs.AbsResourceInstance, total int) QueryComplete {
64+
return QueryComplete{
65+
Address: addr.String(),
66+
ResourceType: addr.Resource.Resource.Type,
67+
Total: total,
68+
}
69+
}
70+
5771
func marshalValues(value cty.Value) map[string]json.RawMessage {
5872
if value == cty.NilVal || value.IsNull() {
5973
return nil

0 commit comments

Comments
 (0)