From 33a0b3c24417c03dccbb859cc4dcddefc0d87c09 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 30 Nov 2016 14:18:40 -0700 Subject: [PATCH] Warn user that hosts should be stopped before delete --- cmd/rm.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/rm.go b/cmd/rm.go index 7581176f6..5455c298c 100644 --- a/cmd/rm.go +++ b/cmd/rm.go @@ -1,6 +1,7 @@ package cmd import ( + "fmt" "strings" "github.com/rancher/go-rancher/v2" @@ -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 }) }