Implement cache migrations

This commit is contained in:
2024-12-31 17:45:45 -05:00
parent 70027a9880
commit 30d86d72ed
5 changed files with 101 additions and 8 deletions

View File

@@ -14,6 +14,8 @@ import (
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
)
const cacheVersion = "v0.1.0"
type Cache struct {
Projects []*projects.Project
Aliases []*ProjectAlias
@@ -27,6 +29,7 @@ type Cache struct {
file string
log *pterm.Logger
path string
CacheVersion string
}
type CacheOpts struct {
@@ -118,6 +121,11 @@ func (c *Cache) Read() error {
d := yaml.NewDecoder(file)
d.Decode(c)
// Perform migrations
if err := c.doMigrations(); err != nil {
c.log.Error("Failed to run cache migrations", c.log.Args("error", err))
}
c.readFromFile = true
return nil
}