builder/vmware: Don't start HTTP server if we specified no files
This commit is contained in:
parent
1a5c9d300f
commit
057d656eda
|
@ -25,7 +25,9 @@ func (s *stepHTTPServer) Run(state map[string]interface{}) multistep.StepAction
|
|||
config := state["config"].(*config)
|
||||
ui := state["ui"].(packer.Ui)
|
||||
|
||||
httpPort := 8080
|
||||
httpPort := 0
|
||||
if config.HTTPDir != "" {
|
||||
httpPort = 8080
|
||||
httpAddr := fmt.Sprintf(":%d", httpPort)
|
||||
|
||||
ui.Say(fmt.Sprintf("Starting HTTP server on port %d", httpPort))
|
||||
|
@ -42,6 +44,7 @@ func (s *stepHTTPServer) Run(state map[string]interface{}) multistep.StepAction
|
|||
fileServer := http.FileServer(http.Dir(config.HTTPDir))
|
||||
server := &http.Server{Addr: httpAddr, Handler: fileServer}
|
||||
go server.Serve(s.l)
|
||||
}
|
||||
|
||||
// Save the address into the state so it can be accessed in the future
|
||||
state["http_port"] = httpPort
|
||||
|
|
Loading…
Reference in New Issue