diff --git a/builder/oracle/classic/config_test.go b/builder/oracle/classic/config_test.go index 195e104a8..81b8f0344 100644 --- a/builder/oracle/classic/config_test.go +++ b/builder/oracle/classic/config_test.go @@ -54,6 +54,6 @@ func TestValidationsIgnoresOptional(t *testing.T) { delete(tc, "ssh_username") _, err := NewConfig(tc) 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()) } } diff --git a/builder/oracle/classic/step_create_ip_reservation.go b/builder/oracle/classic/step_create_ip_reservation.go index cee4a62e8..ca324b7e0 100644 --- a/builder/oracle/classic/step_create_ip_reservation.go +++ b/builder/oracle/classic/step_create_ip_reservation.go @@ -42,5 +42,16 @@ func (s *stepCreateIPReservation) Run(_ context.Context, state multistep.StateBa } 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()) + } + }