hashicorp / hashicorp/terraform-exec

API: Consider io.Reader/Writer instead of string when input/output may be large

Open
#321 0 comments 0 reactions 0 assignees View on GitHub
thinking
Dominant language
Go
Stars
786
Forks
129
PR merge metrics
No merged PRs in 30d

Description

Another "consider" issue to figure out before v1.0.0, though this one is fairly well approachable via experimentation.

Certain tfexec functions take the whole state as input or return it as output, currently:
- [`func (tf *Terraform) Show(ctx context.Context, opts ...ShowOption) (*tfjson.State, error)`](https://pkg.go.dev/github.com/hashicorp/terraform-exec@v0.17.0/tfexec#Terraform.Show)
- [`func (tf *Terraform) ShowStateFile(ctx context.Context, statePath string, opts ...ShowOption) (*tfjson.State, error)`](https://pkg.go.dev/github.com/hashicorp/terraform-exec@v0.17.0/tfexec#Terraform.ShowStateFile)
- [`func (tf *Terraform) StatePull(ctx context.Context, opts ...StatePullOption) (string, error)`](https://pkg.go.dev/github.com/hashicorp/terraform-exec@v0.17.0/tfexec#Terraform.StatePull)

The state being sometimes returned as `*tfjson.State` and other times as a `string`, our first goal here should be to make the return type consistent.

Other functions whose return values may be very large include:
- [`func (tf *Terraform) Graph(ctx context.Context, opts ...GraphOption) (string, error)`](https://pkg.go.dev/github.com/hashicorp/terraform-exec@v0.17.0/tfexec#Terraform.Graph)
- [`func (tf *Terraform) ProvidersSchema(ctx context.Context) (*tfjson.ProviderSchemas, error)`](https://pkg.go.dev/github.com/hashicorp/terraform-exec@v0.17.0/tfexec#Terraform.ProvidersSchema)
- [`func (tf *Terraform) Validate(ctx context.Context) (*tfjson.ValidateOutput, error)`](https://pkg.go.dev/github.com/hashicorp/terraform-exec@v0.17.0/tfexec#Terraform.Validate)

We should investigate, and preferably add tests for, the possibility that very large inputs or outputs to these functions could cause problems. Return types should be adjusted accordingly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.