Closed MrFreezeex closed 2 years ago
Ah yes indeed, I need to fix some type in the tests
I also removed all the GetOk call while building the ForemanHost struct as if the schema attribute is computed this method always return true (https://github.com/hashicorp/terraform-plugin-sdk/blob/9bdb216a4ab835003a624b0a15ac39c58ef2861e/helper/schema/resource_diff.go#L386).
Wow. I never realized that. Thats all still code from wayfair and I presumed its basically just a != nil check.
I also removed all the GetOk call while building the ForemanHost struct as if the schema attribute is computed this method always return true (https://github.com/hashicorp/terraform-plugin-sdk/blob/9bdb216a4ab835003a624b0a15ac39c58ef2861e/helper/schema/resource_diff.go#L386).
Wow. I never realized that. Thats all still code from wayfair and I presumed its basically just a != nil check.
Yes... Fortunately for us the foreman api is forgiving if you give him a bunch of id that equals to 0 etc that sort of works.
Ah yes indeed, I need to fix some type in the tests
Should be good now :+1:
The first commit add a
managed
field to host. This allow to not specify the mac address/ip address if you set it to false (not sure if this is redundant to manage_build, I think it should be ok like that though).The second commit refactor a bit the ForemanHost mainly adding a bunch of omitempty (and having *int instead of int so that omitempty actually works), removing the custom marshaling and making
ComputeAttributes
type a little more precise (from interface{} to map[string]interface{}). I also removed all theGetOk
call while building the ForemanHost struct as if the schema attribute iscomputed
this method always returntruefalse (https://github.com/hashicorp/terraform-plugin-sdk/blob/9bdb216a4ab835003a624b0a15ac39c58ef2861e/helper/schema/resource_diff.go#L386).