mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-13 18:50:11 -04:00
add source image id to build from PARtifact
This commit is contained in:
parent
06fb597185
commit
3c5c61cd2a
1 changed files with 8 additions and 2 deletions
|
|
@ -104,7 +104,6 @@ func (b *Bucket) RegisterBuildForComponent(sourceName string) {
|
|||
// CreateInitialBuildForIteration will create a build entry on the HCP Packer Registry for the named componentType.
|
||||
// This initial creation is needed so that Packer can properly track when an iteration is complete.
|
||||
func (b *Bucket) CreateInitialBuildForIteration(ctx context.Context, componentType string) error {
|
||||
|
||||
status := models.HashicorpCloudPackerBuildStatusUNSET
|
||||
buildInput := &models.HashicorpCloudPackerCreateBuildRequest{
|
||||
BucketSlug: b.Slug,
|
||||
|
|
@ -214,16 +213,23 @@ func (b *Bucket) markBuildComplete(ctx context.Context, name string) error {
|
|||
return fmt.Errorf("setting a build to DONE with no published images is not currently supported.")
|
||||
}
|
||||
|
||||
var providerName string
|
||||
var providerName, sourceID string
|
||||
images := make([]*models.HashicorpCloudPackerImageCreateBody, 0, len(buildToUpdate.Images))
|
||||
for _, image := range buildToUpdate.Images {
|
||||
// These values will always be the same for all images in a single build,
|
||||
// so we can just set it inside the loop without consequence
|
||||
if providerName == "" {
|
||||
providerName = image.ProviderName
|
||||
}
|
||||
if image.SourceImageID != "" {
|
||||
sourceID = image.SourceImageID
|
||||
}
|
||||
|
||||
images = append(images, &models.HashicorpCloudPackerImageCreateBody{ImageID: image.ImageID, Region: image.ProviderRegion})
|
||||
}
|
||||
|
||||
buildInput.Updates.CloudProvider = providerName
|
||||
buildInput.Updates.SourceImageID = sourceID
|
||||
buildInput.Updates.Images = images
|
||||
|
||||
_, err := UpdateBuild(ctx, b.client, buildInput)
|
||||
|
|
|
|||
Loading…
Reference in a new issue