Skip to content

Commit

Permalink
Fixes the addTags bug when copy image
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhu36 committed May 8, 2021
1 parent 31e438e commit 4ed795d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/bosh-alicloud-cpi/action/create_stemcell.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ func (a CreateStemcellMethod) copyImage(stemcellId string, props StemcellProps)
a.cleanUp(imageId)
return "", bosherr.WrapError(err, "Failed to copy Alicloud Image")
}
//打标签
imageTags := map[string]string{
"Copied": props.OSSObject,
}
err = a.instances.AddTags(imageId, imageTags)
if err != nil {
return "", bosherr.WrapErrorf(err, "Failed to add tags %v to %s", imageTags, imageId)
//打标签,用于后续删除 full stemcell
if props.OSSObject != "" {
imageTags := map[string]string{
"Copied": props.OSSObject,
}
err = a.instances.AddTags(imageId, imageTags)
if err != nil {
return "", bosherr.WrapErrorf(err, "Failed to add tags %v to %s", imageTags, imageId)
}
}
a.Logger.Debug(alicloud.AlicloudImageServiceTag, "Copy Alicloud Image %s success", imageId)
return imageId, nil
Expand Down

0 comments on commit 4ed795d

Please # to comment.