Merge pull request #5345 from esirK/ft-fix-created-at-bug

Always set app created-at via property instead of introspecting on folder creation time
This commit is contained in:
josegonzalez authored and GitHub committed 2022-11-22 21:52:22 -05:00
commit 8aa60f239d
3 files changed
+36 -4

No files matched your search

+5
View File
@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"os" "os"
"strings" "strings"
"time"
"github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/common"
) )
@@ -35,6 +36,10 @@ func createApp(appName string) error {
common.LogInfo1Quiet(fmt.Sprintf("Creating %s...", appName)) common.LogInfo1Quiet(fmt.Sprintf("Creating %s...", appName))
os.MkdirAll(common.AppRoot(appName), 0755) os.MkdirAll(common.AppRoot(appName), 0755)
if err := common.PropertyWrite("apps", appName, "created-at", fmt.Sprintf("%d", time.Now().Unix())); err != nil {
return err
}
if err := common.PlugnTrigger("post-create", []string{appName}...); err != nil { if err := common.PlugnTrigger("post-create", []string{appName}...); err != nil {
return err return err
} }
+3 -4
View File
@@ -2,7 +2,7 @@ package apps
import ( import (
"fmt" "fmt"
"os" "strings"
"github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/common"
) )
@@ -33,12 +33,11 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
} }
func reportCreatedAt(appName string) string { func reportCreatedAt(appName string) string {
fi, err := os.Stat(common.AppRoot(appName)) createdAt, err := common.PropertyListGet("apps", appName, "created-at")
if err != nil { if err != nil {
return "" return ""
} }
return fmt.Sprint(strings.Join(createdAt, ","))
return fmt.Sprint(fi.ModTime().Unix())
} }
func reportDeploySource(appName string) string { func reportDeploySource(appName string) string {
+28
View File
@@ -2,6 +2,8 @@ package apps
import ( import (
"fmt" "fmt"
"os"
"time"
"github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/common"
) )
@@ -41,6 +43,32 @@ func TriggerInstall() error {
return fmt.Errorf("Unable to install the apps plugin: %s", err.Error()) return fmt.Errorf("Unable to install the apps plugin: %s", err.Error())
} }
apps, err := common.UnfilteredDokkuApps()
if err != nil {
return nil
}
// migrate all created-at values from app mod-time to property
for _, appName := range apps {
if common.PropertyExists("apps", appName, "created-at") {
continue
}
fi, err := os.Stat(common.AppRoot(appName))
if err != nil {
// if we can't get the time, just write the current one out as a stub
if err := common.PropertyWrite("apps", appName, "created-at", fmt.Sprintf("%d", time.Now().Unix())); err != nil {
return err
}
continue
}
if err := common.PropertyWrite("apps", appName, "created-at", fmt.Sprintf("%d", fi.ModTime().Unix())); err != nil {
return err
}
}
return nil return nil
} }