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
Conversation
53252d3
to
bf14b7b
Compare
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.
@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": { |
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.
"sharing_profile": { | |
"sharing": { |
Per the reference naming doc should we shorten this to just sharing
?
}, false), | ||
}, | ||
|
||
"community_gallery_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.
"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": { |
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.
"public_name": { | |
"name": { |
Should this be shortened to just name
?
ForceNew: true, | ||
ValidateFunc: validation.StringIsNotEmpty, | ||
}, | ||
"public_name_prefix": { |
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.
"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 { |
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.
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 { |
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.
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`. |
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.
~> **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
?
Hi @WodansSon thanks for reviewing the change! I've updated the pr according to your comment, please take a look. |
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.
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. |
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.
The docs say this is in preview, so could we add a note explaining that:
* `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. |
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.
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>
azurerm_shared_image_gallery
- support for Community Galleryazurerm_shared_image_gallery
- support for the sharing block
To add support for Community Shared Gallery.
Added tests as well for VM to consume Community Shared Image Version:
terraform-provider-azurerm/internal/services/compute/linux_virtual_machine_resource.go
Line 302 in f70fe79
There will be another possible value for
sharing_profile.permission
to support Direct Shared Gallery after its GA socommunity_gallery_info
is set tooptional