Skip to content

Commit

Permalink
Warn user that hosts should be stopped before delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Nov 30, 2016
1 parent 83a2057 commit 33a0b3c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/rm.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"strings"

"github.com/rancher/go-rancher/v2"
Expand Down Expand Up @@ -49,6 +50,13 @@ func deleteResources(ctx *cli.Context) error {
}
}
}
return resource.Id, c.Delete(resource)
err := c.Delete(resource)
if v, ok := err.(*client.ApiError); ok && v.StatusCode == 405 {
action, err := pickAction(resource, "stop", "deactivate")
if err == nil {
fmt.Printf("error: Must call %s on %s %s before removing\n", action, resource.Type, resource.Id)
}
}
return resource.Id, err
})
}

0 comments on commit 33a0b3c

Please sign in to comment.