Commit 04563764 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

`packer build` now communicates through RPC!

parent 91ade277
...@@ -3,6 +3,8 @@ OK_COLOR=\x1b[32;01m ...@@ -3,6 +3,8 @@ OK_COLOR=\x1b[32;01m
ERROR_COLOR=\x1b[31;01m ERROR_COLOR=\x1b[31;01m
WARN_COLOR=\x1b[33;01m WARN_COLOR=\x1b[33;01m
export ROOTDIR=$(CURDIR)
all: all:
@mkdir -p bin/ @mkdir -p bin/
go get -d -v ./... go get -d -v ./...
......
...@@ -3,12 +3,18 @@ package main ...@@ -3,12 +3,18 @@ package main
import ( import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer/plugin"
"fmt" "fmt"
"os" "os"
"os/exec"
) )
func main() { func main() {
envConfig := packer.DefaultEnvironmentConfig() envConfig := packer.DefaultEnvironmentConfig()
envConfig.Commands = []string{"build"}
envConfig.CommandFunc = func(n string) packer.Command {
return plugin.Command(exec.Command("bin/packer-build"))
}
env, err := packer.NewEnvironment(envConfig) env, err := packer.NewEnvironment(envConfig)
if err != nil { if err != nil {
......
...@@ -11,7 +11,13 @@ import ( ...@@ -11,7 +11,13 @@ import (
) )
func Command(cmd *exec.Cmd) packer.Command { func Command(cmd *exec.Cmd) packer.Command {
env := []string{
"PACKER_PLUGIN_MIN_PORT=10000",
"PACKER_PLUGIN_MAX_PORT=25000",
}
out := new(bytes.Buffer) out := new(bytes.Buffer)
cmd.Env = append(cmd.Env, env...)
cmd.Stdout = out cmd.Stdout = out
cmd.Start() cmd.Start()
......
plugin: plugin:
go get -d -v ./... go get -d -v ./...
go build -v -o $(CURDIR)/bin/packer-build go build -v -o $(ROOTDIR)/bin/packer-build
format: format:
go fmt ./... go fmt ./...
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment