github.com/rothwerx/packer@v0.9.0/builder/amazon/chroot/step_early_unflock.go (about)

     1  package chroot
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/mitchellh/multistep"
     6  	"github.com/mitchellh/packer/packer"
     7  	"log"
     8  )
     9  
    10  // StepEarlyUnflock unlocks the flock.
    11  type StepEarlyUnflock struct{}
    12  
    13  func (s *StepEarlyUnflock) Run(state multistep.StateBag) multistep.StepAction {
    14  	cleanup := state.Get("flock_cleanup").(Cleanup)
    15  	ui := state.Get("ui").(packer.Ui)
    16  
    17  	log.Println("Unlocking file lock...")
    18  	if err := cleanup.CleanupFunc(state); err != nil {
    19  		err := fmt.Errorf("Error unlocking file lock: %s", err)
    20  		state.Put("error", err)
    21  		ui.Error(err.Error())
    22  		return multistep.ActionHalt
    23  	}
    24  
    25  	return multistep.ActionContinue
    26  }
    27  
    28  func (s *StepEarlyUnflock) Cleanup(state multistep.StateBag) {}