refactor: remove oapi references in bsusurrogate builder
This commit is contained in:
parent
aa3ec3fd0f
commit
49e4d83cd7
|
@ -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")},
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
osccommon "github.com/hashicorp/packer/builder/osc/common"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/outscale/osc-go/oapi"
|
||||
"github.com/outscale/osc-sdk-go/osc"
|
||||
)
|
||||
|
||||
|
@ -23,7 +22,6 @@ type StepRegisterOMI struct {
|
|||
|
||||
func (s *StepRegisterOMI) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
config := state.Get("config").(*Config)
|
||||
oapiconn := state.Get("oapi").(*oapi.Client)
|
||||
oscconn := state.Get("osc").(*osc.APIClient)
|
||||
snapshotIds := state.Get("snapshot_ids").(map[string]string)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
@ -51,7 +49,7 @@ func (s *StepRegisterOMI) Run(ctx context.Context, state multistep.StateBag) mul
|
|||
// Set the OMI ID in the state
|
||||
ui.Say(fmt.Sprintf("OMI: %s", registerResp.Image.ImageId))
|
||||
omis := make(map[string]string)
|
||||
omis[oapiconn.GetConfig().Region] = registerResp.Image.ImageId
|
||||
omis[s.RawRegion] = registerResp.Image.ImageId
|
||||
state.Put("omis", omis)
|
||||
|
||||
// Wait for the image to become ready
|
||||
|
|
Loading…
Reference in New Issue