Skip to content

Commit 5aa2179

Browse files
committed
GetURL() should fail is the machine is stopped
Signed-off-by: David Gageot <david@gageot.net>
1 parent 01f3a45 commit 5aa2179

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/google/google.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,19 @@ func (d *Driver) GetURL() (string, error) {
229229

230230
// GetIP returns the IP address of the GCE instance.
231231
func (d *Driver) GetIP() (string, error) {
232+
machineState, err := d.GetState()
233+
if err != nil {
234+
return "", err
235+
}
236+
if machineState != state.Running {
237+
return "", drivers.ErrHostIsNotRunning
238+
}
239+
232240
c, err := newComputeUtil(d)
233241
if err != nil {
234242
return "", err
235243
}
244+
236245
return c.ip()
237246
}
238247

0 commit comments

Comments
 (0)