-
Notifications
You must be signed in to change notification settings - Fork 15
Added support for Private Image Sharing #391
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package linode | |
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/hashicorp/packer-plugin-sdk/multistep" | ||
| packersdk "github.com/hashicorp/packer-plugin-sdk/packer" | ||
|
|
@@ -45,6 +46,39 @@ func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) mul | |
| return handleError("Failed to wait for image creation", err) | ||
| } | ||
|
|
||
| // Add the image to Image Share Groups, if configured | ||
| if len(c.ImageShareGroupIDs) > 0 { | ||
| for _, shareGroupID := range c.ImageShareGroupIDs { | ||
| ui.Say(fmt.Sprintf( | ||
| "Adding image %s to image share group %d...", | ||
| image.ID, | ||
| shareGroupID, | ||
| )) | ||
|
|
||
| _, err := s.client.ImageShareGroupAddImages( | ||
| ctx, | ||
| shareGroupID, | ||
| linodego.ImageShareGroupAddImagesOptions{ | ||
| Images: []linodego.ImageShareGroupImage{ | ||
| { | ||
| ID: image.ID, | ||
| }, | ||
| }, | ||
| }, | ||
| ) | ||
|
Comment on lines
+58
to
+68
|
||
| if err != nil { | ||
| return handleError( | ||
| fmt.Sprintf( | ||
| "Failed to add image %s to image share group %d", | ||
| image.ID, | ||
| shareGroupID, | ||
| ), | ||
| err, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if len(c.ImageRegions) > 0 { | ||
| image, err = s.client.ReplicateImage(ctx, image.ID, linodego.ImageReplicateOptions{ | ||
| Regions: c.ImageRegions, | ||
|
|
||
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.
Images are being added to share groups sequentially. If multiple share groups are specified, this could be slow. Consider whether parallel addition or batch operations are supported by the API to improve performance.
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 API only supports adding images to one Share Group at a time so I think adding them sequentially is fine. Again, happy to hear others' thoughts.