cleanup
This commit is contained in:
parent
bf0a320125
commit
cba4d3235f
|
@ -51,7 +51,6 @@ func (s *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag)
|
||||||
vncPort := state.Get("vnc_port").(uint)
|
vncPort := state.Get("vnc_port").(uint)
|
||||||
vncPassword := state.Get("vnc_password")
|
vncPassword := state.Get("vnc_password")
|
||||||
|
|
||||||
// ----------------
|
|
||||||
// Wait the for the vm to boot.
|
// Wait the for the vm to boot.
|
||||||
if int64(s.BootWait) > 0 {
|
if int64(s.BootWait) > 0 {
|
||||||
ui.Say(fmt.Sprintf("Waiting %s for boot...", s.BootWait.String()))
|
ui.Say(fmt.Sprintf("Waiting %s for boot...", s.BootWait.String()))
|
||||||
|
@ -62,7 +61,6 @@ func (s *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag)
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----------------
|
|
||||||
|
|
||||||
var pauseFn multistep.DebugPauseFn
|
var pauseFn multistep.DebugPauseFn
|
||||||
if debug {
|
if debug {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
TODO:
|
TODO:
|
||||||
* tests
|
* tests
|
||||||
* fix vbox tests
|
* fix vbox tests
|
||||||
* comments
|
|
||||||
* lower-case specials
|
* lower-case specials
|
||||||
* pc-at abstraction
|
* pc-at abstraction
|
||||||
* check that `<del>` works. It's different now.
|
* check that `<del>` works. It's different now.
|
||||||
|
@ -33,15 +32,6 @@ const (
|
||||||
KeyPress
|
KeyPress
|
||||||
)
|
)
|
||||||
|
|
||||||
func onOffToAction(t string) KeyAction {
|
|
||||||
if strings.EqualFold(t, "on") {
|
|
||||||
return KeyOn
|
|
||||||
} else if strings.EqualFold(t, "off") {
|
|
||||||
return KeyOff
|
|
||||||
}
|
|
||||||
panic(fmt.Sprintf("Unknown state '%s'. Expecting On or Off.", t))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k KeyAction) String() string {
|
func (k KeyAction) String() string {
|
||||||
switch k {
|
switch k {
|
||||||
case KeyOn:
|
case KeyOn:
|
||||||
|
@ -60,6 +50,7 @@ type expression interface {
|
||||||
|
|
||||||
type expressionSequence []expression
|
type expressionSequence []expression
|
||||||
|
|
||||||
|
// Do executes every expression in the sequence and then finalizes the driver.
|
||||||
func (s expressionSequence) Do(ctx context.Context, b BCDriver) error {
|
func (s expressionSequence) Do(ctx context.Context, b BCDriver) error {
|
||||||
for _, exp := range s {
|
for _, exp := range s {
|
||||||
if err := exp.Do(ctx, b); err != nil {
|
if err := exp.Do(ctx, b); err != nil {
|
||||||
|
@ -70,7 +61,7 @@ func (s expressionSequence) Do(ctx context.Context, b BCDriver) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateExpressionSequence generates a sequence of expressions from the
|
// GenerateExpressionSequence generates a sequence of expressions from the
|
||||||
// given command.
|
// given command. This is the primary entry point to the boot command parser.
|
||||||
func GenerateExpressionSequence(command string) (expressionSequence, error) {
|
func GenerateExpressionSequence(command string) (expressionSequence, error) {
|
||||||
got, err := ParseReader("", strings.NewReader(command))
|
got, err := ParseReader("", strings.NewReader(command))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -90,6 +81,8 @@ type waitExpression struct {
|
||||||
d time.Duration
|
d time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do waits the amount of time described by the expression. It is cancellable
|
||||||
|
// through the context.
|
||||||
func (w *waitExpression) Do(ctx context.Context, _ BCDriver) error {
|
func (w *waitExpression) Do(ctx context.Context, _ BCDriver) error {
|
||||||
log.Printf("[INFO] Waiting %s", w.d)
|
log.Printf("[INFO] Waiting %s", w.d)
|
||||||
select {
|
select {
|
||||||
|
@ -109,6 +102,7 @@ type specialExpression struct {
|
||||||
action KeyAction
|
action KeyAction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do sends the special command to the driver, along with the key action.
|
||||||
func (s *specialExpression) Do(ctx context.Context, driver BCDriver) error {
|
func (s *specialExpression) Do(ctx context.Context, driver BCDriver) error {
|
||||||
return driver.SendSpecial(s.s, s.action)
|
return driver.SendSpecial(s.s, s.action)
|
||||||
}
|
}
|
||||||
|
@ -122,6 +116,7 @@ type literal struct {
|
||||||
action KeyAction
|
action KeyAction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do sends the key to the driver, along with the key action.
|
||||||
func (l *literal) Do(ctx context.Context, driver BCDriver) error {
|
func (l *literal) Do(ctx context.Context, driver BCDriver) error {
|
||||||
return driver.SendKey(l.s, l.action)
|
return driver.SendKey(l.s, l.action)
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,6 +174,7 @@ func (d *pcATDriver) SendSpecial(special string, action KeyAction) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send stores the codes in an internal buffer. Use finalize to flush them.
|
||||||
func (d *pcATDriver) send(codes []string) {
|
func (d *pcATDriver) send(codes []string) {
|
||||||
d.buffer = append(d.buffer, codes)
|
d.buffer = append(d.buffer, codes)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue