2017-09-12 11:30:39 -04:00
|
|
|
package oci
|
2017-02-13 05:35:14 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"os"
|
|
|
|
|
2018-01-19 19:18:44 -05:00
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
2017-04-07 06:20:33 -04:00
|
|
|
"github.com/hashicorp/packer/packer"
|
2017-02-13 05:35:14 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// TODO(apryde): It would be good not to have to write a key file to disk to
|
|
|
|
// load the config.
|
|
|
|
func baseTestConfig() *Config {
|
2018-04-11 05:20:40 -04:00
|
|
|
_, keyFile, err := baseTestConfigWithTmpKeyFile()
|
2017-02-13 05:35:14 -05:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2019-12-17 05:25:56 -05:00
|
|
|
var c Config
|
|
|
|
err = c.Prepare(map[string]interface{}{
|
2018-04-11 05:20:40 -04:00
|
|
|
"availability_domain": "aaaa:US-ASHBURN-AD-1",
|
2017-02-13 05:35:14 -05:00
|
|
|
|
|
|
|
// Image
|
2018-04-11 05:20:40 -04:00
|
|
|
"base_image_ocid": "ocid1.image.oc1.iad.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
2017-02-13 05:35:14 -05:00
|
|
|
"shape": "VM.Standard1.1",
|
|
|
|
"image_name": "HelloWorld",
|
2018-04-11 05:20:40 -04:00
|
|
|
"region": "us-ashburn-1",
|
2017-02-13 05:35:14 -05:00
|
|
|
|
|
|
|
// Networking
|
2018-04-11 05:20:40 -04:00
|
|
|
"subnet_ocid": "ocid1.subnet.oc1.iad.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
2017-02-13 05:35:14 -05:00
|
|
|
|
|
|
|
// AccessConfig
|
2018-04-11 05:20:40 -04:00
|
|
|
"user_ocid": "ocid1.user.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
|
|
"tenancy_ocid": "ocid1.tenancy.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
|
|
"fingerprint": "70:04:5z:b3:19:ab:90:75:a4:1f:50:d4:c7:c3:33:20",
|
2017-02-13 05:35:14 -05:00
|
|
|
"key_file": keyFile.Name(),
|
2017-02-13 07:37:27 -05:00
|
|
|
|
|
|
|
// Comm
|
2018-02-13 08:20:26 -05:00
|
|
|
"ssh_username": "opc",
|
|
|
|
"use_private_ip": false,
|
2017-02-13 05:35:14 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
// Once we have a config object they key file isn't re-read so we can
|
|
|
|
// remove it now.
|
|
|
|
os.Remove(keyFile.Name())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-12-17 05:25:56 -05:00
|
|
|
return &c
|
2017-02-13 05:35:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func testState() multistep.StateBag {
|
2018-02-13 08:20:26 -05:00
|
|
|
baseTestConfig := baseTestConfig()
|
2017-02-13 05:35:14 -05:00
|
|
|
state := new(multistep.BasicStateBag)
|
2018-02-13 08:20:26 -05:00
|
|
|
state.Put("config", baseTestConfig)
|
|
|
|
state.Put("driver", &driverMock{cfg: baseTestConfig})
|
2017-02-13 05:35:14 -05:00
|
|
|
state.Put("hook", &packer.MockHook{})
|
|
|
|
state.Put("ui", &packer.BasicUi{
|
|
|
|
Reader: new(bytes.Buffer),
|
|
|
|
Writer: new(bytes.Buffer),
|
|
|
|
})
|
|
|
|
return state
|
|
|
|
}
|