github.com/phobos182/packer@v0.2.3-0.20130819023704-c84d2aeffc68/builder/vmware/step_compact_disk.go (about) 1 package vmware 2 3 import ( 4 "fmt" 5 "github.com/mitchellh/multistep" 6 "github.com/mitchellh/packer/packer" 7 "log" 8 ) 9 10 // This step compacts the virtual disk for the VM unless the "skip_compaction" 11 // boolean is true. 12 // 13 // Uses: 14 // config *config 15 // driver Driver 16 // full_disk_path string 17 // ui packer.Ui 18 // 19 // Produces: 20 // <nothing> 21 type stepCompactDisk struct{} 22 23 func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction { 24 config := state["config"].(*config) 25 driver := state["driver"].(Driver) 26 ui := state["ui"].(packer.Ui) 27 full_disk_path := state["full_disk_path"].(string) 28 29 if config.SkipCompaction == true { 30 log.Println("Skipping disk compaction step...") 31 return multistep.ActionContinue 32 } 33 34 ui.Say("Compacting the disk image") 35 if err := driver.CompactDisk(full_disk_path); err != nil { 36 state["error"] = fmt.Errorf("Error compacting disk: %s", err) 37 return multistep.ActionHalt 38 } 39 40 return multistep.ActionContinue 41 } 42 43 func (stepCompactDisk) Cleanup(map[string]interface{}) {}