removed unused builder/azure/common/lin.StepGeneralizeOS struct
This commit is contained in:
parent
3d46fbd4f2
commit
7c358eed2f
|
@ -1,56 +0,0 @@
|
||||||
package lin
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/hashicorp/packer/helper/multistep"
|
|
||||||
"github.com/hashicorp/packer/packer"
|
|
||||||
)
|
|
||||||
|
|
||||||
type StepGeneralizeOS struct {
|
|
||||||
Command string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StepGeneralizeOS) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
|
||||||
ui := state.Get("ui").(packer.Ui)
|
|
||||||
comm := state.Get("communicator").(packer.Communicator)
|
|
||||||
|
|
||||||
ui.Say("Executing OS generalization...")
|
|
||||||
|
|
||||||
var stdout, stderr bytes.Buffer
|
|
||||||
cmd := &packer.RemoteCmd{
|
|
||||||
Command: s.Command,
|
|
||||||
Stdout: &stdout,
|
|
||||||
Stderr: &stderr,
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := comm.Start(cmd); err != nil {
|
|
||||||
err = fmt.Errorf("Failed executing OS generalization command: %s", err)
|
|
||||||
state.Put("error", err)
|
|
||||||
ui.Error(err.Error())
|
|
||||||
return multistep.ActionHalt
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for the command to run
|
|
||||||
cmd.Wait()
|
|
||||||
|
|
||||||
// If the command failed to run, notify the user in some way.
|
|
||||||
if cmd.ExitStatus != 0 {
|
|
||||||
state.Put("error", fmt.Errorf(
|
|
||||||
"OS generalization has non-zero exit status.\n\nStdout: %s\n\nStderr: %s",
|
|
||||||
stdout.String(), stderr.String()))
|
|
||||||
return multistep.ActionHalt
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("OS generalization stdout: %s", stdout.String())
|
|
||||||
log.Printf("OS generalization stderr: %s", stderr.String())
|
|
||||||
|
|
||||||
return multistep.ActionContinue
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StepGeneralizeOS) Cleanup(state multistep.StateBag) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
Loading…
Reference in New Issue