-
Notifications
You must be signed in to change notification settings - Fork 75
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
Refactored Get* methods 1 #217
Conversation
* Add function getUuidFromHref * Add function getOrgHREFById, to retrieve an HREF from an Org/AdminOrg ID * Add method vcdClient.ReadOrgByName * Add method vcdClient.ReadOrgById * Add method vcdClient.ReadOrgByNameOrId * Add method vcdClient.ReadOrg (using a struct) * Add method vcdClient.ReadAdminOrgByName * Add method vcdClient.ReadAdminOrgById * Add method vcdClient.ReadAdminOrgByNameOrId * Add method vcdClient.ReadAdminOrg (using a struct) * Add Fix for values in OrgGeneralSettings, which are ignored unless some fields are always filled. * Add test for getUuidFromHref * Add tests for all Read* methods * Add more tests for Org creation
* Deprecate GetOrgByName, GetAdminOrgByName * Replace all calls to the above function with the new Read* methods
The Update method was not updating the Org description
* Remove unused methods GetOrg and GetAdminOrg * Remove corresponding tests * Standardize deprecation messages * Add Changelog entries * Add CODING_PRINCIPLES.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of good things:
- Thanks for the "it's" fixes...
- +1 for fixed deprecation messages
- Nice on the coding guidelines.
One spot/question - in many places I see:
check.Assert(org, NotNil)
check.Assert(err, IsNil)
Wouldn't it be more informative to swap them so that check.Assert(err, IsNil)
is the first check. If it does not pass the dumped err
should be more informative than a simply nil
struct pointer of some type.
Fetch* functions were renamed in this PR, but they should have been deprecated instead. They are now reinstated as wrappers to the intended replacements
Make the flow easier to read and more robust
Make the functions that retrieve by name or ID easier to read and more robust against corner cases where an error may occur in the first search that is not a ErrorEntityNotFound, and would possibly return stale results.
This move allows running org tests by tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few more unordered err
assertions.
@@ -337,6 +365,37 @@ func getOrgHREF(vcdClient *VCDClient, orgName string) (string, error) { | |||
return "", fmt.Errorf("couldn't find org with name: %s. Please check Org name as it is case sensitive", orgName) | |||
} | |||
|
|||
// Returns the HREF of the org from the org ID | |||
func getOrgHREFById(vcdClient *VCDClient, orgId string) (string, error) { | |||
orgListHREF := vcdClient.Client.VCDHREF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's possible to Query using href/id in filter? this would make function very simple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query struct doesn't have Organization info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, It would be need to add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice code structure and a well written guideline too!
This is the first batch of changes to support the creation of data sources in terraform-provider-vcd.
Changes:
Note: when a function was returning
Org
and other entities, I have only changed the return type forOrg
(from structure to pointer), leaving the refactoring of the other return types when we tackle the other entities.