packer-cn/builder/triton/ssh.go

27 lines
506 B
Go
Raw Normal View History

package triton
import (
"log"
2020-12-17 16:29:25 -05:00
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func commHost(host string) func(multistep.StateBag) (string, error) {
return func(state multistep.StateBag) (string, error) {
if host != "" {
log.Printf("Using host value: %s", host)
return host, nil
}
driver := state.Get("driver").(Driver)
machineID := state.Get("machine").(string)
machine, err := driver.GetMachineIP(machineID)
if err != nil {
return "", err
}
return machine, nil
}
}