-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding show option to configure JSON decoding #426
Labels
enhancement
New feature or request
Comments
bendbennett
added a commit
that referenced
this issue
Dec 8, 2023
bendbennett
added a commit
that referenced
this issue
Dec 8, 2023
bendbennett
added a commit
that referenced
this issue
Dec 8, 2023
bendbennett
added a commit
that referenced
this issue
Dec 8, 2023
bendbennett
added a commit
that referenced
this issue
Dec 14, 2023
bendbennett
added a commit
that referenced
this issue
Dec 14, 2023
bendbennett
added a commit
that referenced
this issue
Dec 18, 2023
bendbennett
added a commit
that referenced
this issue
Dec 20, 2023
kmoe
added a commit
that referenced
this issue
Dec 20, 2023
* Adding ShowOption for JSON handling (#426) * Temporarily pointing at terraform-json PR for dependent changes (#426) * Ignoring fields that differ between TF versions (#426) * Rename structs and func (#426) * Removing redundant struct (#426) * Update tfexec/options.go Co-authored-by: kmoe <[email protected]> * Updating to use renamed struct (#426) * Bumping terraform-json to v0.19.0 (#426) --------- Co-authored-by: kmoe <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Background
The terraform-exec Go module explicitly sets the
useJSONNumber
field to true on the tfjson.State struct by calling UseJSONNumber(true) within the Show() method prior to the implicit call to UnmarshalJSON() on tfjson.State. As a consequence, numerical values that are returned when the state is obtained by calling the Show() method on terraform-exec are of typejson.Number
.The tfjson.Plan struct does not currently surface a way to modify the handling of numerical values when decoding JSON, as there is no
useJSONNumber
field on the tfjson.Plan struct, and no correspondingUseJSONNumber()
method for setting such a field. As a consequence, numerical values that are obtained when calling methods such as ShowPlanFile() are of typefloat64
.A PR has been opened on terraform-plugin-json which adds a
useJSONNumber
field to the tfjson.Plan struct, adds a correspondingUseJSONNumber()
method for setting such a field, and correspondingly modifies theUnmarshalJSON()
method on tfjson.Plan to take the value ofuseJSONNumber
into account.Use-Case
This RFC proposes extending plan check functionality within terraform-plugin-testing to add plan checks for resource attributes and outputs values with a known value and type. Prototyping these known type and value plan checks revealed the limitations of numerical values being of type
float64
in tfjson.Plan in terms of being able to check their values.Proposal
Implementations of ShowOption could be extended to include a
JSONOption
which could contain configuration used to determine how JSON decoding should be handled. Adding such an option would be contingent upon the changes included in the PR on terraform-plugin-json. This would provide a mechanism for callers of, for instance, ShowPlanFile, to be able to obtain numerical values in tfjson.Plan as typejson.Number
.The text was updated successfully, but these errors were encountered: