2016-04-14 20:29:27 -04:00
|
|
|
package triton
|
|
|
|
|
|
|
|
import (
|
2019-07-02 16:56:28 -04:00
|
|
|
"log"
|
|
|
|
|
2020-12-17 16:29:25 -05:00
|
|
|
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
2016-04-14 20:29:27 -04:00
|
|
|
)
|
|
|
|
|
2019-07-02 16:56:28 -04:00
|
|
|
func commHost(host string) func(multistep.StateBag) (string, error) {
|
|
|
|
return func(state multistep.StateBag) (string, error) {
|
|
|
|
if host != "" {
|
2020-01-30 18:22:22 -05:00
|
|
|
log.Printf("Using host value: %s", host)
|
2019-07-02 16:56:28 -04:00
|
|
|
return host, nil
|
|
|
|
}
|
2016-04-14 20:29:27 -04:00
|
|
|
|
2019-07-02 16:56:28 -04:00
|
|
|
driver := state.Get("driver").(Driver)
|
|
|
|
machineID := state.Get("machine").(string)
|
2016-04-14 20:29:27 -04:00
|
|
|
|
2019-07-02 16:56:28 -04:00
|
|
|
machine, err := driver.GetMachineIP(machineID)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
return machine, nil
|
|
|
|
}
|
2016-04-14 20:29:27 -04:00
|
|
|
}
|