diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index 886d728aa..1aeec4e11 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -3,9 +3,11 @@ package bsusurrogate import ( + "crypto/tls" "errors" "fmt" "log" + "net/http" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/common" @@ -13,6 +15,7 @@ import ( "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" + "github.com/outscale/osc-go/oapi" ) const BuilderId = "digitalonus.osc.bsusurrogate" @@ -102,7 +105,32 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { } func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) { - log.Println("Running Outscale Builder...") + clientConfig, err := b.config.Config() + if err != nil { + return nil, err + } + + skipClient := &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + }, + } + + oapiconn := oapi.NewClient(clientConfig, skipClient) + + // Setup the state bag and initial state for the steps + state := new(multistep.BasicStateBag) + state.Put("config", &b.config) + state.Put("oapi", oapiconn) + state.Put("clientConfig", clientConfig) + state.Put("hook", hook) + state.Put("ui", ui) + + steps := []multistep.Step{} + + b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner.Run(state) + return nil, nil }