Open BBBmau opened 7 months ago
Hey there @BBBmau 👋🏻 ,
Tuples are structural types where the type is made up of each exact element type, so I believe your example of adding a new element to the tuple should result in a difference between types.
For example, these two tuple outputs are different types:
output "tuple_one" {
# tuple[string]
value = ["test"]
}
output "tuple_two" {
# tuple[string, string]
value = ["test", "test_two"]
}
{
"version": 4,
"terraform_version": "1.8.0",
"serial": 28,
"lineage": "87f4a8d4-57e7-2f4e-d081-aef9e7e6b675",
"outputs": {
"tuple_one": {
"value": [
"test"
],
"type": [
"tuple",
[
"string"
]
]
},
"tuple_two": {
"value": [
"test",
"test_two"
],
"type": [
"tuple",
[
"string",
"string"
]
]
}
},
"resources": [],
"check_results": null
}
If they were a collection type, like a list which has a single element type, then they would be considered an equal type (which I know this kubernetes_manifest
resource is dynamic, so it unfortunately can't force that scenario on the practitioner):
output "tuple_one" {
# list(string)
value = tolist(["test"])
}
output "tuple_two" {
# list(string)
value = tolist(["test", "test_two"])
}
{
"version": 4,
"terraform_version": "1.8.0",
"serial": 29,
"lineage": "87f4a8d4-57e7-2f4e-d081-aef9e7e6b675",
"outputs": {
"tuple_one": {
"value": [
"test"
],
"type": [
"list",
"string"
]
},
"tuple_two": {
"value": [
"test",
"test_two"
],
"type": [
"list",
"string"
]
}
},
"resources": [],
"check_results": null
}
I'd need to dig into it deeper, but I think Diff
may have a bug that is allowing tuples and lists to be considered equivalent types when comparing, which shouldn't be the expected behavior (based on how Terraform defines the tuple type)
This occurs when checking for a Type change between two configs that share have different values but still share the same type. Despite this it still returns the wrong bool.
Using Diff instead results in the expected output of no type being present.
terraform-plugin-go version
Relevant provider source code
Terraform Configuration Files
Expected Behavior
Should have returned that no type change was present
Actual Behavior
Type change was present when adding/removing from the tuple.
Steps to Reproduce
Please list the full steps required to reproduce the issue, for example:
terraform init
terraform apply
The change will be reproducible once this PR is merged. https://github.com/hashicorp/terraform-provider-kubernetes/pull/2437
A simpler config can be used, the provided config was the one that was first brought to attention the different behavior of
Equal()
andDiff()