Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resource list usage of "parent" with entities depending on Org #1140

Merged
merged 6 commits into from
Oct 20, 2023

Conversation

dataclouder
Copy link
Collaborator

Entities depending directly on an organization should use the "org" field to identify its parent.
The "parent" field, which is intended for intermediate entities, should not be used for this purpose.
However, if users fill the "parent" field instead of "org", they get an ambiguous error, which doesn't explain what has happened.

This change allows vcd_resource_list to consider both "org" and "parent" fields, as well as the "org" field in the provider block.
The change is transparent for users. If the "parent" field was used instead of "org", the organization is retrieved without complaints. In case of error, they get a clear message about what is missing.

Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
* Add "parent" field into consideration when "org" is empty
* Use client.GetAdminOrg, which uses the provider "org" field if the above
  ones are empty.
* client.GetAdminOrg also returns a better error message

Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Copy link
Collaborator

@adambarreiro adambarreiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@carmine73
Copy link

Is there a reason why org defined at provider level is not used? Is it just for resource and not for datasource?

provider "vcd" {
  ...
  org                  = var.org.name # default for resources
  ...
}

@dataclouder
Copy link
Collaborator Author

Is there a reason why org defined at provider level is not used? Is it just for resource and not for datasource?

It is for both. The reason it was not used is just a plain bug.

@carmine73
Copy link

Anyway, the main point of the fix is making sure that the "org" from the provider is being used when the one in the data source is missing.

Oh yes, you already wrote it.
Thanks

Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
Signed-off-by: Giuseppe Maxia <gmaxia@vmware.com>
@dataclouder dataclouder removed the request for review from Didainius October 20, 2023 12:10
@dataclouder dataclouder merged commit dadb8ea into vmware:main Oct 20, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants