-
Notifications
You must be signed in to change notification settings - Fork 242
Open
Labels
bugSomething isn't workingSomething isn't working
Description
SDK version
2.37.0
Relevant provider source code
terraform-plugin-sdk/helper/schema/resource_data.go
Lines 92 to 108 in 77f585e
| func (d *ResourceData) GetOk(key string) (interface{}, bool) { | |
| r := d.getRaw(key, getSourceSet) | |
| exists := r.Exists && !r.Computed | |
| if exists { | |
| // If it exists, we also want to verify it is not the zero-value. | |
| value := r.Value | |
| zero := r.Schema.Type.Zero() | |
| if eq, ok := value.(Equal); ok { | |
| exists = !eq.Equal(zero) | |
| } else { | |
| exists = !reflect.DeepEqual(value, zero) | |
| } | |
| } | |
| return r.Value, exists | |
| } |
Terraform Configuration Files
resource "tfe_workspace" "foobar" {
...
auto_apply = false
}Debug Output
Expected Behavior
GetOk should return false, true meaning the value of auto_apply is false and true it exists in HCL code
Actual Behavior
because GetOk determines that the zero value of a interface-bool is false, exists = !reflect.DeepEqual(value, zero) sets exists to false and GetOk returns false,false
Workaround
Current workaround is to use GetOkExists for bool values. Which has been deprecated
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working