github.com/sneal/packer@v0.5.2/builder/docker/step_pull.go (about) 1 package docker 2 3 import ( 4 "fmt" 5 "github.com/mitchellh/multistep" 6 "github.com/mitchellh/packer/packer" 7 "log" 8 ) 9 10 type StepPull struct{} 11 12 func (s *StepPull) Run(state multistep.StateBag) multistep.StepAction { 13 config := state.Get("config").(*Config) 14 driver := state.Get("driver").(Driver) 15 ui := state.Get("ui").(packer.Ui) 16 17 if !config.Pull { 18 log.Println("Pull disabled, won't docker pull") 19 return multistep.ActionContinue 20 } 21 22 ui.Say(fmt.Sprintf("Pulling Docker image: %s", config.Image)) 23 if err := driver.Pull(config.Image); err != nil { 24 err := fmt.Errorf("Error pulling Docker image: %s", err) 25 state.Put("error", err) 26 ui.Error(err.Error()) 27 return multistep.ActionHalt 28 } 29 30 return multistep.ActionContinue 31 } 32 33 func (s *StepPull) Cleanup(state multistep.StateBag) { 34 }