fix: allow renaming old applications to new format
0.22.0 changed allowed values for app names, making it more difficult for users to fix their app names - you need to either downgrade+rename or recreate the app. The `apps:rename` command can now rename these old applications to the new standard. Also drop some app name verification from internal commands. Duplicate verification doesn't help much, and though it isn't excessively slow, it does prevent us from running commands against old apps that exist. Refs #4267
This commit is contained in:
@@ -83,6 +83,17 @@ func destroyApp(appName string) error {
|
||||
|
||||
forceCleanup := true
|
||||
common.DockerCleanup(appName, forceCleanup)
|
||||
|
||||
// remove contents for apps that are symlinks to other folders
|
||||
if err := os.RemoveAll(fmt.Sprintf("%v/", common.AppRoot(appName))); err != nil {
|
||||
common.LogWarn(err.Error())
|
||||
}
|
||||
|
||||
// then remove the folder and/or the symlink
|
||||
if err := os.RemoveAll(common.AppRoot(appName)); err != nil {
|
||||
common.LogWarn(err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ func CommandClone(oldAppName string, newAppName string, skipDeploy bool, ignoreE
|
||||
return errors.New("Please specify an new app name")
|
||||
}
|
||||
|
||||
if err := common.IsValidAppName(oldAppName); err != nil {
|
||||
if err := common.VerifyAppName(oldAppName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -26,10 +26,6 @@ func CommandClone(oldAppName string, newAppName string, skipDeploy bool, ignoreE
|
||||
return err
|
||||
}
|
||||
|
||||
if err := appExists(oldAppName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := appExists(newAppName); err == nil {
|
||||
if ignoreExisting {
|
||||
common.LogWarn("Name is already taken")
|
||||
@@ -61,8 +57,8 @@ func CommandClone(oldAppName string, newAppName string, skipDeploy bool, ignoreE
|
||||
|
||||
// CommandCreate creates app via command line
|
||||
func CommandCreate(appName string) error {
|
||||
if appName == "" {
|
||||
return errors.New("Please specify an app to run the command on")
|
||||
if err := common.IsValidAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return createApp(appName)
|
||||
@@ -70,8 +66,8 @@ func CommandCreate(appName string) error {
|
||||
|
||||
// CommandDestroy destroys an app
|
||||
func CommandDestroy(appName string, force bool) error {
|
||||
if appName == "" {
|
||||
return errors.New("Please specify an app to run the command on")
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if force {
|
||||
@@ -153,7 +149,7 @@ func CommandRename(oldAppName string, newAppName string, skipDeploy bool) error
|
||||
return errors.New("Please specify an new app name")
|
||||
}
|
||||
|
||||
if err := common.IsValidAppName(oldAppName); err != nil {
|
||||
if err := common.VerifyAppName(oldAppName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -161,10 +157,6 @@ func CommandRename(oldAppName string, newAppName string, skipDeploy bool) error
|
||||
return err
|
||||
}
|
||||
|
||||
if err := appExists(oldAppName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := appExists(newAppName); err == nil {
|
||||
return errors.New("Name is already taken")
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package apps
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
@@ -31,16 +28,6 @@ func TriggerAppMaybeCreate(appName string) error {
|
||||
func TriggerPostDelete(appName string) error {
|
||||
imageRepo := common.GetAppImageRepo(appName)
|
||||
|
||||
// remove contents for apps that are symlinks to other folders
|
||||
if err := os.RemoveAll(fmt.Sprintf("%v/", common.AppRoot(appName))); err != nil {
|
||||
common.LogWarn(err.Error())
|
||||
}
|
||||
|
||||
// then remove the folder and/or the symlink
|
||||
if err := os.RemoveAll(common.AppRoot(appName)); err != nil {
|
||||
common.LogWarn(err.Error())
|
||||
}
|
||||
|
||||
imagesByAppLabel, err := listImagesByAppLabel(appName)
|
||||
if err != nil {
|
||||
common.LogWarn(err.Error())
|
||||
|
||||
Reference in New Issue
Block a user