|
|
|
|
@ -6,10 +6,8 @@ package bsusurrogate
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"crypto/tls"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/hcl/v2/hcldec"
|
|
|
|
|
osccommon "github.com/hashicorp/packer/builder/osc/common"
|
|
|
|
|
@ -19,7 +17,6 @@ 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 = "oapi.outscale.bsusurrogate"
|
|
|
|
|
@ -104,25 +101,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
oscConn := b.config.NewOSCClient()
|
|
|
|
|
|
|
|
|
|
// 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("osc", oscConn)
|
|
|
|
|
state.Put("accessConfig", &b.config.AccessConfig)
|
|
|
|
|
state.Put("hook", hook)
|
|
|
|
|
@ -251,7 +234,6 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
|
|
|
|
|
artifact := &osccommon.Artifact{
|
|
|
|
|
Omis: omis.(map[string]string),
|
|
|
|
|
BuilderIdValue: BuilderId,
|
|
|
|
|
Config: clientConfig,
|
|
|
|
|
StateData: map[string]interface{}{"generated_data": state.Get("generated_data")},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|