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 metadata functionality for vAppTemplate and media image/item #225

Merged
merged 9 commits into from
Aug 2, 2019
Merged

Add metadata functionality for vAppTemplate and media image/item #225

merged 9 commits into from
Aug 2, 2019

Conversation

vbauzys
Copy link
Contributor

@vbauzys vbauzys commented Aug 1, 2019

Ref:https://github.com/terraform-providers/terraform-provider-vcd/issues/285
Added new CRUD metadata functions for vApp template and media image.
Also new refresh functions for vApp template and media image.

This new functions will be used in terraform to provide resources metadata capabilities.

Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

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

preliminary review

return vAppTemplate, nil
}

// AddMetadata() function calls private function addMetadata() with vAppTemplate.client and vAppTemplate.VAppTemplate.HREF
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment should say AddMetadataAsync

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}

// AddMetadata() function calls private function addMetadata() with vAppTemplate.client and vAppTemplate.VAppTemplate.HREF
// which adds metadata key, value pair provided as input.
Copy link
Contributor

Choose a reason for hiding this comment

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

"key, value" -> "key/value"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

return getMetadata(mediaItem.client, mediaItem.MediaItem.HREF)
}

// AddMetadata() function adds metadata key, value pair provided as input.
Copy link
Contributor

Choose a reason for hiding this comment

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

"key, value" -> "key/value"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}
err = task.WaitTaskCompletion()
if err != nil {
return nil, fmt.Errorf("error completing add metadata for media item task: %#v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

"%#v" -> "%s"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed


err = mediaItem.Refresh()
if err != nil {
return nil, fmt.Errorf("error refreshing media item: %#v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

"%#v" -> "%s"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed


uploadTask, err := catalog.UploadMediaImage(itemName, "upload from test", vcd.config.Media.MediaPath, 1024)
check.Assert(err, IsNil)
err = uploadTask.WaitTaskCompletion()
Copy link
Contributor

Choose a reason for hiding this comment

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

task should be checked before usage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added


// Check if metadata was added correctly
metadata, err := mediaItem.GetMetadata()
check.Assert(err, IsNil)
Copy link
Contributor

Choose a reason for hiding this comment

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

metadata should be also checked

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

}

catItem, err := cat.FindCatalogItem(vcd.config.VCD.Catalog.CatalogItem)
check.Assert(err, IsNil)
Copy link
Contributor

Choose a reason for hiding this comment

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

catItem should be also checked

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed


// Get VAppTemplate
vAppTemplate, err := catItem.GetVAppTemplate()
check.Assert(err, IsNil)
Copy link
Contributor

Choose a reason for hiding this comment

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

vAppTemplate should be also checked

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

oldVAppTemplate := vAppTemplate

err = vAppTemplate.Refresh()
check.Assert(oldVAppTemplate.VAppTemplate, Equals, vAppTemplate.VAppTemplate)
Copy link
Contributor

Choose a reason for hiding this comment

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

err should be checked

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

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.

Just a few comments inline.

vbauzys added 4 commits August 2, 2019 07:48
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>
vbauzys added 4 commits August 2, 2019 09:43
Signed-off-by: Vaidotas Bauzys <[email protected]>
Signed-off-by: Vaidotas Bauzys <[email protected]>

# Conflicts:
#	CHANGELOG.md
Signed-off-by: Vaidotas Bauzys <[email protected]>

# Conflicts:
#	CHANGELOG.md
Signed-off-by: Vaidotas Bauzys <[email protected]>
Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

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

LGTM

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.

LGTM

@vbauzys vbauzys merged commit aeb4ec7 into vmware:master Aug 2, 2019
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.

5 participants