diff --git a/builder/osc/bsu/builder_acc_test.go b/builder/osc/bsu/builder_acc_test.go new file mode 100644 index 000000000..441820e8d --- /dev/null +++ b/builder/osc/bsu/builder_acc_test.go @@ -0,0 +1,55 @@ +/* +Deregister the test image with +aws oapi deregister-image --image-id $(aws oapi describe-images --output text --filters "Name=name,Values=packer-test-packer-test-dereg" --query 'Images[*].{ID:ImageId}') +*/ +package bsu + +import ( + "crypto/tls" + "net/http" + "testing" + + "github.com/hashicorp/packer/builder/osc/common" + builderT "github.com/hashicorp/packer/helper/builder/testing" + "github.com/outscale/osc-go/oapi" +) + +func TestBuilderAcc_basic(t *testing.T) { + builderT.Test(t, builderT.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Builder: &Builder{}, + Template: testBuilderAccBasic, + }) +} + +func testAccPreCheck(t *testing.T) { +} + +func testOAPIConn() (*oapi.Client, error) { + access := &common.AccessConfig{RawRegion: "us-east-1"} + clientConfig, err := access.Config() + if err != nil { + return nil, err + } + + skipClient := &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + }, + } + + return oapi.NewClient(clientConfig, skipClient), nil +} + +const testBuilderAccBasic = ` +{ + "builders": [{ + "type": "test", + "region": "eu-west-2", + "vm_type": "m3.medium", + "source_omi": "omi-76b2a71e", + "ssh_username": "ubuntu", + "omi_name": "packer-test {{timestamp}}" + }] +} +` diff --git a/builder/osc/common/step_source_omi_info.go b/builder/osc/common/step_source_omi_info.go index 05c9e7d41..f602b5cc7 100644 --- a/builder/osc/common/step_source_omi_info.go +++ b/builder/osc/common/step_source_omi_info.go @@ -63,7 +63,7 @@ func (s *StepSourceOMIInfo) Run(_ context.Context, state multistep.StateBag) mul params.Filters.AccountIds = s.OmiFilters.Owners } - log.Printf("Using OMI Filters %v", params) + log.Printf("Using OMI Filters %#v", params) imageResp, err := oapiconn.POST_ReadImages(params) if err != nil { err := fmt.Errorf("Error querying OMI: %s", err) @@ -73,7 +73,7 @@ func (s *StepSourceOMIInfo) Run(_ context.Context, state multistep.StateBag) mul } if len(imageResp.OK.Images) == 0 { - err := fmt.Errorf("No OMI was found matching filters: %v", params) + err := fmt.Errorf("No OMI was found matching filters: %#v", params) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt diff --git a/command/plugin.go b/command/plugin.go index 627c45375..e44708122 100644 --- a/command/plugin.go +++ b/command/plugin.go @@ -38,6 +38,7 @@ import ( openstackbuilder "github.com/hashicorp/packer/builder/openstack" oracleclassicbuilder "github.com/hashicorp/packer/builder/oracle/classic" oracleocibuilder "github.com/hashicorp/packer/builder/oracle/oci" + oscbsubuilder "github.com/hashicorp/packer/builder/osc/bsu" oscbsusurrogatebuilder "github.com/hashicorp/packer/builder/osc/bsusurrogate" parallelsisobuilder "github.com/hashicorp/packer/builder/parallels/iso" parallelspvmbuilder "github.com/hashicorp/packer/builder/parallels/pvm" @@ -122,6 +123,7 @@ var Builders = map[string]packer.Builder{ "openstack": new(openstackbuilder.Builder), "oracle-classic": new(oracleclassicbuilder.Builder), "oracle-oci": new(oracleocibuilder.Builder), + "osc-bsu": new(oscbsubuilder.Builder), "osc-bsusurrogate": new(oscbsusurrogatebuilder.Builder), "parallels-iso": new(parallelsisobuilder.Builder), "parallels-pvm": new(parallelspvmbuilder.Builder),