2020-09-16 04:08:44 -04:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2020-11-17 19:31:03 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
|
2020-11-12 17:44:02 -05:00
|
|
|
"github.com/hashicorp/packer/packer-plugin-sdk/packerbuilderdata"
|
2020-09-16 04:08:44 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type StepSetGeneratedData struct {
|
2020-11-04 18:44:05 -05:00
|
|
|
GeneratedData *packerbuilderdata.GeneratedData
|
2020-09-16 04:08:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepSetGeneratedData) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
|
|
|
driver := state.Get("driver").(Driver)
|
|
|
|
|
|
|
|
sha256 := "ERR_IMAGE_SHA256_NOT_FOUND"
|
|
|
|
if imageId, ok := state.GetOk("image_id"); ok {
|
|
|
|
s256, err := driver.Sha256(imageId.(string))
|
|
|
|
if err == nil {
|
|
|
|
sha256 = s256
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.GeneratedData.Put("ImageSha256", sha256)
|
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *StepSetGeneratedData) Cleanup(_ multistep.StateBag) {
|
|
|
|
// No cleanup...
|
|
|
|
}
|