hcp: reject template type changes between builds

As a follow-up to tracking the template type for an iteration, we
actively check that it remains consistent between two invocations of
packer, and reject the update if it is not the case.
pull/12150/head
Lucas Bajolet 4 years ago committed by Lucas Bajolet
parent 6d0045607c
commit 4846301ff4

@ -338,6 +338,13 @@ func (b *Bucket) initializeIteration(ctx context.Context, templateType models.Ha
return fmt.Errorf("failed to initialize iteration details for Bucket %s with error: %w", b.Slug, err)
}
if iteration.TemplateType != nil &&
*iteration.TemplateType != models.HashicorpCloudPackerIterationTemplateTypeTEMPLATETYPEUNSET &&
*iteration.TemplateType != templateType {
return fmt.Errorf("This iteration was initially created with a %[2]s template. Changing from %[2]s to %[1]s is not supported.",
templateType, *iteration.TemplateType)
}
log.Println("[TRACE] a valid iteration was retrieved with the id", iteration.ID)
b.Iteration.ID = iteration.ID

Loading…
Cancel
Save