github.com/mmcquillan/packer@v1.1.1-0.20171009221028-c85cf0483a5d/builder/oracle/oci/step_test.go (about) 1 package oci 2 3 import ( 4 "bytes" 5 "os" 6 7 "github.com/hashicorp/packer/packer" 8 "github.com/mitchellh/multistep" 9 10 client "github.com/hashicorp/packer/builder/oracle/oci/client" 11 ) 12 13 // TODO(apryde): It would be good not to have to write a key file to disk to 14 // load the config. 15 func baseTestConfig() *Config { 16 _, keyFile, err := client.BaseTestConfig() 17 if err != nil { 18 panic(err) 19 } 20 21 cfg, err := NewConfig(map[string]interface{}{ 22 "availability_domain": "aaaa:PHX-AD-3", 23 24 // Image 25 "base_image_ocid": "ocd1...", 26 "shape": "VM.Standard1.1", 27 "image_name": "HelloWorld", 28 29 // Networking 30 "subnet_ocid": "ocd1...", 31 32 // AccessConfig 33 "user_ocid": "ocid1...", 34 "tenancy_ocid": "ocid1...", 35 "fingerprint": "00:00...", 36 "key_file": keyFile.Name(), 37 38 // Comm 39 "ssh_username": "opc", 40 }) 41 42 // Once we have a config object they key file isn't re-read so we can 43 // remove it now. 44 os.Remove(keyFile.Name()) 45 46 if err != nil { 47 panic(err) 48 } 49 return cfg 50 } 51 52 func testState() multistep.StateBag { 53 state := new(multistep.BasicStateBag) 54 state.Put("config", baseTestConfig()) 55 state.Put("driver", &driverMock{}) 56 state.Put("hook", &packer.MockHook{}) 57 state.Put("ui", &packer.BasicUi{ 58 Reader: new(bytes.Buffer), 59 Writer: new(bytes.Buffer), 60 }) 61 return state 62 }