add UI output with resource names

This commit is contained in:
Matthew Hooker 2018-01-26 13:12:35 -08:00
parent 18ffde4ecf
commit 71acccc1ed
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
3 changed files with 11 additions and 5 deletions

View File

@ -16,7 +16,6 @@ type stepAddKeysToAPI struct{}
func (s *stepAddKeysToAPI) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
// get variables from state
ui := state.Get("ui").(packer.Ui)
ui.Say("Adding SSH keys to API...")
config := state.Get("config").(*Config)
client := state.Get("client").(*compute.ComputeClient)
@ -32,6 +31,8 @@ func (s *stepAddKeysToAPI) Run(_ context.Context, state multistep.StateBag) mult
sshKeyName := fmt.Sprintf("/Compute-%s/%s/packer_generated_key_%s",
config.IdentityDomain, config.Username, uuid_string)
ui.Say(fmt.Sprintf("Creating temporary key: %s", sshKeyName))
sshKeysClient := client.SSHKeys()
sshKeysInput := compute.CreateSSHKeyInput{
Name: sshKeyName,

View File

@ -16,11 +16,11 @@ func (s *stepCreateInstance) Run(_ context.Context, state multistep.StateBag) mu
// get variables from state
ui := state.Get("ui").(packer.Ui)
ui.Say("Creating Instance...")
config := state.Get("config").(*Config)
client := state.Get("client").(*compute.ComputeClient)
keyName := state.Get("key_name").(string)
ipAddName := fmt.Sprintf("ipres_%s", config.ImageName)
ipAddName := state.Get("ipres_name").(string)
secListName := state.Get("security_list").(string)
netInfo := compute.NetworkingInfo{

View File

@ -13,15 +13,19 @@ type stepCreateIPReservation struct{}
func (s *stepCreateIPReservation) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
ui.Say("Creating IP reservation...")
config := state.Get("config").(*Config)
client := state.Get("client").(*compute.ComputeClient)
iprClient := client.IPReservations()
// TODO: add optional Name and Tags
ipresName := fmt.Sprintf("ipres_%s", config.ImageName)
ui.Say(fmt.Sprintf("Creating IP reservation: %s", ipresName))
IPInput := &compute.CreateIPReservationInput{
ParentPool: compute.PublicReservationPool,
Permanent: true,
Name: fmt.Sprintf("ipres_%s", config.ImageName),
Name: ipresName,
}
ipRes, err := iprClient.CreateIPReservation(IPInput)
@ -32,6 +36,7 @@ func (s *stepCreateIPReservation) Run(_ context.Context, state multistep.StateBa
return multistep.ActionHalt
}
state.Put("instance_ip", ipRes.IP)
state.Put("ipres_name", ipresName)
return multistep.ActionContinue
}