From ee0d6d38e02c1332752fd34d9efde7216efecab7 Mon Sep 17 00:00:00 2001 From: Cheng Sun Date: Mon, 8 Dec 2014 16:01:12 +0000 Subject: [PATCH] Replace reflect with type assertion --- builder/xenserver/step_wait.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builder/xenserver/step_wait.go b/builder/xenserver/step_wait.go index 7e250fe..f68dcb9 100644 --- a/builder/xenserver/step_wait.go +++ b/builder/xenserver/step_wait.go @@ -3,7 +3,6 @@ package xenserver import ( "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" - "reflect" "time" ) @@ -39,13 +38,12 @@ func (self *stepWait) Run(state multistep.StateBag) multistep.StepAction { // Hack - should encapsulate this in the client really // This is needed because we can't guarentee the type // returned by the xmlrpc lib will be string - switch reflect.TypeOf(rec["type"]).Kind() { - case reflect.String: - if rec["type"].(string) == "CD" { + if recType, ok := rec["type"].(string); ok { + if recType == "CD" { ui.Say("Ejecting CD...") vbd.Eject() } - default: + } else { break } }