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

Refactor metadata CRUD functions to simplify code #473

Merged
merged 23 commits into from
Jun 3, 2022

Conversation

adambarreiro
Copy link
Collaborator

@adambarreiro adambarreiro commented May 17, 2022

Enhancements

  • Adds the POST operation for metadata, called MergeMetadata and MergeMetadataAsync as it is what it does: Updates existing keys, and adds the non-existing ones. The operation was added to all existing supported VCD entities. The input parameter is the Metadata typedValue and a map with string keys and interface{} values, in order to support the different typed values that metadata can handle in VCD.

Refactoring

  • Moved deprecated functions to the bottom, now they can be easily deleted when a new major comes, as before they were mixed up with new ones.
  • Ordered the functions that were a bit chaotic-ordered. Now they respect the same order always.
  • Moved the getAdminUrl() to a more general place, modified its implementation to avoid coupling with Vdc and also avoid a bug when the method is called with sysadmin user.
  • Deleted a lot of duplicated code in metadata tests.
  • Deleted test Test_DeleteMetadataForXxxx. Now both Add/Delete are in the same test: Test_AddAndDeleteMetadataForXxx to avoid dangling metadata. Anyway, these test will be removed in next major as they test deprecated methods.
  • Fixes findFirstVapp() testing function that didn't return always the defined in configuration vApp. Now it does if present.

Testing

Executed go test -v -tags "metadata" on VCD 10.3.2

Signed-off-by: abarreiro <abarreiro@vmware.com>
abarreiro added 14 commits May 17, 2022 16:58
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Fix
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Fix
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
fmt
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro self-assigned this May 19, 2022
@adambarreiro adambarreiro marked this pull request as ready for review May 19, 2022 11:02
@adambarreiro adambarreiro removed the request for review from dataclouder May 19, 2022 11:02
abarreiro added 2 commits May 19, 2022 15:28
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

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

I hope I didn't miss some tiny value in this maze, but the tests do pass and Terraform should give another layer of check.

A few notes on capitalization in comments (I was constantly overlooking these but @lvirbalas hopefully fixed them in my head for long):

  • Vdc -> VDC (Virtual Data Center)
  • Org (short for Organization)

govcd/metadata.go Outdated Show resolved Hide resolved
abarreiro added 2 commits May 20, 2022 12:35
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Copy link
Contributor

@vbauzys vbauzys left a comment

Choose a reason for hiding this comment

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

LGTM this maze :) we will see in terraform.

.changes/v2.16.0/473-features.md Outdated Show resolved Hide resolved
Signed-off-by: abarreiro <abarreiro@vmware.com>
abarreiro added 3 commits June 2, 2022 09:17
Signed-off-by: abarreiro <abarreiro@vmware.com>
…ctor into refactor-metadata

Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants