fix: check for deployment of app before removing
All checks were successful
continuous-integration/drone/push Build is passing

Closes coop-cloud/go-abra#61.

Fix thanks to @knoflook!
This commit is contained in:
decentral1se 2021-09-05 21:54:52 +02:00
parent 273db078b0
commit cc249e8187
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -49,7 +49,7 @@ var appRemoveCommand = &cli.Command{
logrus.Fatal(err) logrus.Fatal(err)
} }
if !response { if !response {
return errors.New("User aborted app removal") logrus.Fatal("User aborted app removal")
} }
} }
@ -65,6 +65,16 @@ var appRemoveCommand = &cli.Command{
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
if !internal.Force {
// get app status and check if it's deployed
statuses, err := config.GetAppStatuses(appFiles)
if err != nil {
logrus.Fatal(err)
}
if statuses[appName] == "deployed" {
logrus.Fatalf("'%s' is still deployed. Run \"abra app %s undeploy\" or pass --force", appName, appName)
}
}
fs := filters.NewArgs() fs := filters.NewArgs()
fs.Add("name", appName) fs.Add("name", appName)
@ -74,7 +84,6 @@ var appRemoveCommand = &cli.Command{
} }
secrets := make(map[string]string) secrets := make(map[string]string)
if len(secrets) > 0 {
var secretNames []string var secretNames []string
for _, cont := range secretList { for _, cont := range secretList {
@ -82,6 +91,7 @@ var appRemoveCommand = &cli.Command{
secretNames = append(secretNames, cont.Spec.Annotations.Name) secretNames = append(secretNames, cont.Spec.Annotations.Name)
} }
if len(secrets) > 0 {
var secretNamesToRemove []string var secretNamesToRemove []string
if !internal.Force { if !internal.Force {
secretsPrompt := &survey.MultiSelect{ secretsPrompt := &survey.MultiSelect{
@ -112,11 +122,11 @@ var appRemoveCommand = &cli.Command{
} }
var vols []string var vols []string
if len(vols) > 0 {
for _, vol := range volumeList { for _, vol := range volumeList {
vols = append(vols, vol.Name) vols = append(vols, vol.Name)
} }
if len(vols) > 0 {
if Volumes { if Volumes {
var removeVols []string var removeVols []string
if !internal.Force { if !internal.Force {