Skip to content

Commit 086d38c

Browse files
committed
Outlining the marshalling for filling in terraform-json.Query
1 parent 49004cd commit 086d38c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

internal/plugintest/working_dir.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,19 @@ func (wd *WorkingDir) Query(ctx context.Context) ([]string, error) {
532532
var buffer bytes.Buffer
533533
err := wd.tf.QueryJSON(context.Background(), &buffer)
534534

535-
// Marshall buffer? JSON.mashallto___ terraform-json.Query
535+
// terraform-exec also only exposes the raw json writer for now
536+
// So we have to Marshall buffer something like JSON.mashallto___ for terraform-json.Query
537+
/* The struct Terraform is using to encode a query result:
538+
type QueryResult struct {
539+
Address string `json:"address"`
540+
DisplayName string `json:"display_name"`
541+
Identity map[string]json.RawMessage `json:"identity"`
542+
ResourceType string `json:"resource_type"`
543+
ResourceObject map[string]json.RawMessage `json:"resource_object,omitempty"`
544+
Config string `json:"config,omitempty"`
545+
ImportConfig string `json:"import_config,omitempty"`
546+
}
547+
*/
536548

537549
if err != nil {
538550
return nil, fmt.Errorf("error running terraform query command: %w", err)

0 commit comments

Comments
 (0)