DeleteInstance removes an instance
(instance, zone string, wait bool)
| 338 | |
| 339 | // DeleteInstance removes an instance |
| 340 | func (g GCPClient) DeleteInstance(instance, zone string, wait bool) error { |
| 341 | var notFound bool |
| 342 | op, err := g.compute.Instances.Delete(g.projectName, zone, instance).Do() |
| 343 | if err != nil { |
| 344 | if _, ok := err.(*googleapi.Error); !ok { |
| 345 | return err |
| 346 | } |
| 347 | if err.(*googleapi.Error).Code != 404 { |
| 348 | return err |
| 349 | } |
| 350 | notFound = true |
| 351 | } |
| 352 | if !notFound && wait { |
| 353 | log.Infof("Deleting existing instance...") |
| 354 | if err := g.pollZoneOperationStatus(op.Name, zone); err != nil { |
| 355 | return err |
| 356 | } |
| 357 | log.Infof("Instance %s deleted", instance) |
| 358 | } |
| 359 | return nil |
| 360 | } |
| 361 | |
| 362 | // GetInstanceSerialOutput streams the serial output of an instance |
| 363 | func (g GCPClient) GetInstanceSerialOutput(instance, zone string) error { |
no test coverage detected