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

azurerm_shared_image_gallery - support for the sharing block #22221

Merged
merged 2 commits into from Aug 3, 2023

Conversation

myc2h6o
Copy link
Contributor

@myc2h6o myc2h6o commented Jun 20, 2023

To add support for Community Shared Gallery.
Added tests as well for VM to consume Community Shared Image Version:

computeValidate.CommunityGalleryImageVersionID,

There will be another possible value for sharing_profile.permission to support Direct Shared Gallery after its GA so community_gallery_info is set to optional

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jun 21, 2023

Test result:
image

Copy link
Collaborator

@WodansSon WodansSon left a comment

Choose a reason for hiding this comment

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

@myc2h6o thank you so much for this PR. This is looking really good so far, but I did leave a few comments. If you can take a look at those I will be happy to give this a second review to get this merged! 🚀

@@ -53,6 +55,64 @@ func resourceSharedImageGallery() *pluginsdk.Resource {
Optional: true,
},

"sharing_profile": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"sharing_profile": {
"sharing": {

Per the reference naming doc should we shorten this to just sharing?

}, false),
},

"community_gallery_info": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"community_gallery_info": {
"community_gallery": {

Same here, as mentioned above, should we shorten this to just community_gallery?

ForceNew: true,
ValidateFunc: validation.StringIsNotEmpty,
},
"public_name": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"public_name": {
"name": {

Should this be shortened to just name?

ForceNew: true,
ValidateFunc: validation.StringIsNotEmpty,
},
"public_name_prefix": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"public_name_prefix": {
"prefix": {

Would it make more sense if this was just prefix or name_prefix?

@@ -65,6 +125,7 @@ func resourceSharedImageGallery() *pluginsdk.Resource {

func resourceSharedImageGalleryCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since update is now supported I believe we should make this two separate functions (e.g. resourceSharedImageGalleryCreate and resourceSharedImageGalleryUpdate)


if model := resp.Model; model != nil {
if prop := model.Properties; prop != nil && prop.SharingProfile != nil && prop.SharingProfile.Permissions != nil {
if *prop.SharingProfile.Permissions == galleries.GallerySharingPermissionTypesCommunity {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if *prop.SharingProfile.Permissions == galleries.GallerySharingPermissionTypesCommunity {
if pointer.From(prop.SharingProfile.Permissions) == galleries.GallerySharingPermissionTypesCommunity {

To be consistent in the code should we migrate this to use the pointer helper?

NOTE: I am not going to mark all of the * code, but there are a lot of places in the code where this can be migrated as well. WDYT?


* `community_gallery_info` - (Optional) A `community_gallery_info` block as defined below. Changing this forces a new resource to be created.

~> **NOTE** `community_gallery_info` must be set when `permission` is set to `Community`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
~> **NOTE** `community_gallery_info` must be set when `permission` is set to `Community`.
~> **NOTE:** `community_gallery_info` must be set when `permission` is set to `Community`.

Super minor, but should we add a colon : at the end of NOTE?

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jun 25, 2023

Hi @WodansSon thanks for reviewing the change! I've updated the pr according to your comment, please take a look.

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jun 25, 2023

Updated test result:
image

@stephybun stephybun self-assigned this Jun 26, 2023
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM 🎨


A `sharing` block supports the following:

* `permission` - (Required) The permission of the Shared Image Gallery when sharing. The only possible value now is `Community`. Changing this forces a new resource to be created.
Copy link
Member

Choose a reason for hiding this comment

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

The docs say this is in preview, so could we add a note explaining that:

Suggested change
* `permission` - (Required) The permission of the Shared Image Gallery when sharing. The only possible value now is `Community`. Changing this forces a new resource to be created.
* `permission` - (Required) The permission of the Shared Image Gallery when sharing. The only possible value now is `Community`. Changing this forces a new resource to be created.
-> **Note:** This requires that the Preview Feature `Microsoft.Compute/CommunityGalleries` is enabled, see [the documentation](https://learn.microsoft.com/azure/virtual-machines/share-gallery-community?tabs=cli) for more information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for pointing that out, I've updated the document. This shall be GAed already in most of the regions, including the regions used by our acc tests so test subscriptions shall be fine to run the new test

Co-authored-by: stephybun <steph@hashicorp.com>
@katbyte katbyte changed the title azurerm_shared_image_gallery - support for Community Gallery azurerm_shared_image_gallery - support for the sharing block Aug 3, 2023
@katbyte katbyte merged commit 4d1c9bf into hashicorp:main Aug 3, 2023
23 checks passed
katbyte added a commit that referenced this pull request Aug 3, 2023
@github-actions github-actions bot added this to the v3.68.0 milestone Aug 3, 2023
@myc2h6o myc2h6o deleted the shared_gallery branch August 3, 2023 02:01
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.

None yet

4 participants