fix: ensure we migrate data for all golang plugins
This commit is contained in:
1 parent
a8283824a5
commit
af84293c3e
4 files changed
+14
-5
No files matched your search
@@ -139,7 +139,7 @@ func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
|
|||||||
|
|
||||||
// TriggerPostAppRename removes the old app data
|
// TriggerPostAppRename removes the old app data
|
||||||
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
||||||
return common.RemoveAppDataDirectory("app-json", oldAppName)
|
return common.MigrateAppDataDirectory("app-json", oldAppName, newAppName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TriggerPostAppRenameSetup renames app-json files
|
// TriggerPostAppRenameSetup renames app-json files
|
||||||
@@ -162,7 +162,7 @@ func TriggerPostCreate(appName string) error {
|
|||||||
|
|
||||||
// TriggerPostDelete destroys the app-json data for a given app container
|
// TriggerPostDelete destroys the app-json data for a given app container
|
||||||
func TriggerPostDelete(appName string) error {
|
func TriggerPostDelete(appName string) error {
|
||||||
dataErr := os.RemoveAll(common.GetAppDataDirectory("app-json", appName))
|
dataErr := common.RemoveAppDataDirectory("app-json", appName)
|
||||||
propertyErr := common.PropertyDestroy("app-json", appName)
|
propertyErr := common.PropertyDestroy("app-json", appName)
|
||||||
|
|
||||||
if dataErr != nil {
|
if dataErr != nil {
|
||||||
|
|||||||
@@ -46,6 +46,15 @@ func GetDataDirectory(pluginName string) string {
|
|||||||
return filepath.Join(MustGetEnv("DOKKU_LIB_ROOT"), "data", pluginName)
|
return filepath.Join(MustGetEnv("DOKKU_LIB_ROOT"), "data", pluginName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MigrateAppDataDirectory migrates the data directory for one app to another
|
||||||
|
func MigrateAppDataDirectory(pluginName string, oldAppName string, newAppName string) error {
|
||||||
|
if err := CloneAppData(pluginName, oldAppName, newAppName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return RemoveAppDataDirectory(pluginName, oldAppName)
|
||||||
|
}
|
||||||
|
|
||||||
// RemoveAppDataDirectory removes the path to the data directory for the given plugin/app combination
|
// RemoveAppDataDirectory removes the path to the data directory for the given plugin/app combination
|
||||||
func RemoveAppDataDirectory(pluginName, appName string) error {
|
func RemoveAppDataDirectory(pluginName, appName string) error {
|
||||||
return os.RemoveAll(GetAppDataDirectory(pluginName, appName))
|
return os.RemoveAll(GetAppDataDirectory(pluginName, appName))
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
|
|||||||
|
|
||||||
// TriggerPostAppRename removes the old app data
|
// TriggerPostAppRename removes the old app data
|
||||||
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
||||||
return common.RemoveAppDataDirectory("logs", oldAppName)
|
return common.MigrateAppDataDirectory("logs", oldAppName, newAppName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TriggerPostAppRenameSetup renames logs files
|
// TriggerPostAppRenameSetup renames logs files
|
||||||
@@ -141,7 +141,7 @@ func TriggerPostCreate(appName string) error {
|
|||||||
|
|
||||||
// TriggerPostDelete destroys the logs property for a given app container
|
// TriggerPostDelete destroys the logs property for a given app container
|
||||||
func TriggerPostDelete(appName string) error {
|
func TriggerPostDelete(appName string) error {
|
||||||
dataErr := os.RemoveAll(common.GetAppDataDirectory("logs", appName))
|
dataErr := common.RemoveAppDataDirectory("logs", appName)
|
||||||
propertyErr := common.PropertyDestroy("logs", appName)
|
propertyErr := common.PropertyDestroy("logs", appName)
|
||||||
|
|
||||||
if dataErr != nil {
|
if dataErr != nil {
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
|
|||||||
|
|
||||||
// TriggerPostAppRename rebuilds the renamed app
|
// TriggerPostAppRename rebuilds the renamed app
|
||||||
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
func TriggerPostAppRename(oldAppName string, newAppName string) error {
|
||||||
if err := common.RemoveAppDataDirectory("ps", oldAppName); err != nil {
|
if err := common.MigrateAppDataDirectory("ps", oldAppName, newAppName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user