vatesfr / terraform-provider-xenorchestra

Xen Orchestra provider for Terraform
MIT License
150 stars 32 forks source link

> Rather than this just being a string we could use [dataSourceXoaHost](https://github.com/terra-farm/terraform-provider-xenorchestra/blob/6d0b85c152094efd9ee16ad0c8b6a080b701c305/xoa/data_source_host.go#L10) which would give us access to all the attributes that the individual host data source supports. Right now that is just `name_label` and `id` but that could include CPUs, hostnames, memory, XCP version, etc in the future #131

Closed ddelnano closed 3 years ago

ddelnano commented 3 years ago

Rather than this just being a string we could use dataSourceXoaHost which would give us access to all the attributes that the individual host data source supports. Right now that is just name_label and id but that could include CPUs, hostnames, memory, XCP version, etc in the future

I tried really hard to return a slice of hoststructs from GetHostsByPoolName() and reuse the dataSourceXoaHost to set the hosts based on the hostschema. Terraform won't transform the results as needed. This always results in an error telling me :

Invalid address to set: []string{"hosts", "0", "Id"}

I am a little stuck here. Need to do a little more research and debugging. Maybe you have a quick solution for this error?

_Originally posted by @gohumble in https://github.com/terra-farm/terraform-provider-xenorchestra/pull/126#discussion_r584566606_

I wasn't able to reproduce the Invalid address to set: []string{"hosts", "0", "Id"} issue you mentioned above. However, I was able to get the tests passing and ensure that the hosts attribute was properly set. You can see the changes I made on pr-review-add-hosts-data-source

ddelnano commented 3 years ago

I did not mean to create an issue. This was supposed to be a reply on a PR :)