Merge pull request #6588 from xiaozhu36/master
Support describing and checking source image coming from marketplace
This commit is contained in:
commit
2eafdb33a2
|
@ -18,8 +18,12 @@ func (s *stepCheckAlicloudSourceImage) Run(_ context.Context, state multistep.St
|
||||||
client := state.Get("client").(*ecs.Client)
|
client := state.Get("client").(*ecs.Client)
|
||||||
config := state.Get("config").(Config)
|
config := state.Get("config").(Config)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
images, _, err := client.DescribeImages(&ecs.DescribeImagesArgs{RegionId: common.Region(config.AlicloudRegion),
|
args := &ecs.DescribeImagesArgs{
|
||||||
ImageId: config.AlicloudSourceImage})
|
RegionId: common.Region(config.AlicloudRegion),
|
||||||
|
ImageId: config.AlicloudSourceImage,
|
||||||
|
}
|
||||||
|
args.PageSize = 50
|
||||||
|
images, _, err := client.DescribeImages(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error querying alicloud image: %s", err)
|
err := fmt.Errorf("Error querying alicloud image: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
@ -27,6 +31,19 @@ func (s *stepCheckAlicloudSourceImage) Run(_ context.Context, state multistep.St
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Describe markerplace image
|
||||||
|
args.ImageOwnerAlias = ecs.ImageOwnerMarketplace
|
||||||
|
imageMarkets, _, err := client.DescribeImages(args)
|
||||||
|
if err != nil {
|
||||||
|
err := fmt.Errorf("Error querying alicloud marketplace image: %s", err)
|
||||||
|
state.Put("error", err)
|
||||||
|
ui.Error(err.Error())
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
|
if len(imageMarkets) > 0 {
|
||||||
|
images = append(images, imageMarkets...)
|
||||||
|
}
|
||||||
|
|
||||||
if len(images) == 0 {
|
if len(images) == 0 {
|
||||||
err := fmt.Errorf("No alicloud image was found matching filters: %v", config.AlicloudSourceImage)
|
err := fmt.Errorf("No alicloud image was found matching filters: %v", config.AlicloudSourceImage)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
|
Loading…
Reference in New Issue