`packer build` now communicates through RPC!
This commit is contained in:
parent
91ade277a6
commit
04563764a0
2
Makefile
2
Makefile
|
@ -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
|
||||||
|
|
||||||
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 (
|
||||||
)
|
)
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
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 ./...
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue