fix: app rm quitting when there are no secrets/volumes to remove
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
knoflook 2021-09-02 17:52:42 +02:00
parent 063fa66af9
commit c150856a66
Signed by: knoflook
GPG Key ID: D6A1D0E8FC4FEF1C
1 changed files with 55 additions and 51 deletions

View File

@ -65,12 +65,6 @@ var appRemoveCommand = &cli.Command{
logrus.Fatal(err)
}
err = os.Remove(appPath)
if err != nil {
logrus.Fatal(err)
}
logrus.Info(fmt.Sprintf("File: %s removed", appPath))
fs := filters.NewArgs()
fs.Add("name", appName)
secretList, err := cl.SecretList(ctx, types.SecretListOptions{Filters: fs})
@ -79,6 +73,7 @@ var appRemoveCommand = &cli.Command{
}
secrets := make(map[string]string)
if len(secrets) > 0 {
var secretNames []string
for _, cont := range secretList {
@ -105,9 +100,8 @@ var appRemoveCommand = &cli.Command{
}
logrus.Info(fmt.Sprintf("Secret: %s removed", name))
}
if len(secretNamesToRemove) == 0 {
logrus.Info("No secrets were removed")
} else {
logrus.Info("No secrets to remove")
}
volumeListOKBody, err := cl.VolumeList(ctx, fs)
@ -117,6 +111,7 @@ var appRemoveCommand = &cli.Command{
}
var vols []string
if len(vols) > 0 {
for _, vol := range volumeList {
vols = append(vols, vol.Name)
}
@ -143,6 +138,15 @@ var appRemoveCommand = &cli.Command{
} else {
logrus.Info("No volumes were removed")
}
} else {
logrus.Info("No volumes to remove")
}
err = os.Remove(appPath)
if err != nil {
logrus.Fatal(err)
}
logrus.Info(fmt.Sprintf("File: %s removed", appPath))
return nil
},