clean up ip reservations

This commit is contained in:
Megan Marsh 2018-01-26 15:18:33 -08:00
parent 565b660b19
commit 3ee1aa3ed6
2 changed files with 13 additions and 2 deletions

View File

@ -54,6 +54,6 @@ func TestValidationsIgnoresOptional(t *testing.T) {
delete(tc, "ssh_username") delete(tc, "ssh_username")
_, err := NewConfig(tc) _, err := NewConfig(tc)
if err != nil { if err != nil {
t.Fatalf("Test shouldn't care if ssh_username is missing: err: %#v", err.Error()) t.Fatalf("Shouldn't care if ssh_username is missing: err: %#v", err.Error())
} }
} }

View File

@ -42,5 +42,16 @@ func (s *stepCreateIPReservation) Run(_ context.Context, state multistep.StateBa
} }
func (s *stepCreateIPReservation) Cleanup(state multistep.StateBag) { func (s *stepCreateIPReservation) Cleanup(state multistep.StateBag) {
// TODO: delete ip reservation ui := state.Get("ui").(packer.Ui)
ui.Message("Cleaning up IP reservations...")
client := state.Get("client").(*compute.ComputeClient)
ipResName := state.Get("ipres_name").(string)
input := compute.DeleteIPReservationInput{Name: ipResName}
ipClient := client.IPReservations()
err := ipClient.DeleteIPReservation(&input)
if err != nil {
fmt.Printf("error deleting IP reservation: %s", err.Error())
}
} }