terraform-provider-foreman
terraform-provider-foreman copied to clipboard
Handle usage of location_id and organization_id automatically based on Foreman version
Currently, the README and the docs refer to the usage of location_id
and organization_id
as follows:
README:
In case you are still using an older version of Foreman with disabled organizations and locations (< 1.21), you need to disable organizations and locations in the provider by setting
organization_id
andlocation_id
to a value < 0.
Docs:
location_id - (Optional) The location for all resources requested and created by the provider. Defaults to "0". Set organization_id and location_id to a value < 0 if you need to disable Locations and Organizations on Foreman older than 1.21
In the code, this is handled inside this API wrapper function:
https://github.com/terraform-coop/terraform-provider-foreman/blob/61176efe92608cb3f4d7505667c21c42c11ecff6/foreman/api/client.go#L421-L429
My proposal would be to automatically check the Foreman version at the initialisation phase of the API client and handle all relevant cases internally. The version can be queried via the /api/status
endpoint as an authenticated user:
{
"result": "ok",
"status": 200,
"version": "3.7.0",
"api_version": 2
}
Now, since the usage of Foreman versions 1.x is hopefully small (1.20 was released in Nov 2018, with 1.21 following in Feb 2019), this might be a benefit for compatibility for these versions but does not justify directly jumping to an implementation (which might break things).
So, for reference and discussion, this issue serves as a reference regarding this topic.