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

Add vcd_catalog_vapp_template resource and data source for managing vApp Templates and deprecate vcd_catalog_item #899

Merged
merged 68 commits into from
Oct 19, 2022

Conversation

adambarreiro
Copy link
Collaborator

@adambarreiro adambarreiro commented Aug 10, 2022

Overview

This PR adds the resource and data source vcd_catalog_vapp_template to be able to upload, manage and fetch vApp Templates. This resource and data source is very similar to the existing vcd_catalog_item, in fact the idea is to potentially deprecate the latter once other resources like vcd_vm and vcd_vapp_vm are adjusted to use vApp Templates instead of Catalog Items.

Detailed description

As #502 mentions, current vcd_catalog_item implementation is an hybrid of Catalog Item and vApp Template. In order to decouple both concepts, this PR adds the resource and data source vcd_catalog_vapp_template which only considers vApp Templates.

As v3.8.0 doesn't break compatibility, vcd_catalog_item resource and data source specification and source code are preserved as-is with minor code changes that doesn't affect its behaviour.

vcd_catalog_item is NOT deprecated in this PR as it can still be used in the vcd_vm and vcd_vapp_vm resources. A new PR must be done to adjust these two resources and be able to deprecate vcd_catalog_item

  • resource_vcd_catalog_vapp_template.go: New resource for vApp Template

  • datasource_vcd_catalog_vapp_template.go: New data source for vApp Template

  • catalogitem.go: Removed the comment stating that findCatalogItem should be changed, as there is findVAppTemplate instead (see "Other comments").

  • filter_get.go: Created getVappTemplateByVdcAndFilter to be able to fetch vApp Templates by VDC instead of Catalog: getVappTemplateByCatalogAndFilter.

  • vcd/config_test.go: Added required entry in configuration for a vApp Template present in NSX-T backed VDC: nsxtCatalogItem.

Other comments

  • resource_vcd_catalog_vapp_template.go has a new function findVAppTemplate that behaves similarly to findCatalogItem (in fact it started as a clone).
    I must admit that I'm not very happy with the implementation of this function, as the resulting code is quite complex and hard to read. The situation here is that I tried to split it in little functions to reduce complexity and comply a bit more with SRP, but in exchange the vcd package got polluted with these tiny semantic functions that were not quite re-usable. So I finally decided to have this big function. Let me know your thoughts about this.

Testing

  • All tests with tag catalog pass
  • Tested manually resource/vcd_catalog_vapp_template and datasource/vcd_catalog_vapp_template
    • Data source with VDC and filters
    • Data source with Catalog and filters
    • Data source with VDC
    • Data source with Catalog
    • Resource CRUD
  • Tested manually resource/vcd_catalog_item and datasource/vcd_catalog_item to avoid regressions
  • Run acceptance tests on VCD 10.3.x
  • Run acceptance tests on VCD 10.4.x

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>
…ider-vcd into add-catalog-vapp-template

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>
@adambarreiro adambarreiro self-assigned this Aug 10, 2022
#
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>
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>
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>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
.changes/v3.8.0/899-features.md Show resolved Hide resolved
.changes/v3.8.0/899-features.md Show resolved Hide resolved
vcd/resource_vcd_catalog_item.go Show resolved Hide resolved
website/docs/d/catalog_vapp_template.html.markdown Outdated Show resolved Hide resolved
website/docs/r/catalog_vapp_template.html.markdown Outdated Show resolved Hide resolved
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.

A few inline comments. Looks good otherwise - just double check that catalog tests use NSX-T VDC and templates - this should save us refactoring headache in future and add to CDS testing.

vcd/resource_vcd_catalog_vapp_template.go Outdated Show resolved Hide resolved
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

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

LGTM! Looking forward to the needed changes in VM to be able to deprecate the catalog item.

Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro merged commit d9aa0ed into vmware:main Oct 19, 2022
@adambarreiro adambarreiro deleted the add-catalog-vapp-template branch October 19, 2022 09:26
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