Skip to content

Commit

Permalink
force recreation of local OEMfied images if they deemed too old
Browse files Browse the repository at this point in the history
- this will allow us for transparent migrations any time we
  find the need to add or modify hooks in the images we generate

Signed-off-by: António Meireles <[email protected]>
  • Loading branch information
AntonioMeireles committed Jan 8, 2016
1 parent 6514fef commit 0eb0dc4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/spf13/viper"
)

const LatestImageBreackage = "2016-01-08T16:00:00WET"

type (
vmContext struct{ vm *VMInfo }
sessionContext struct {
Expand Down
25 changes: 18 additions & 7 deletions list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"time"

"github.com/blang/semver"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -87,9 +88,10 @@ func init() {

func localImages() (local map[string]semver.Versions, err error) {
var (
files []os.FileInfo
f os.FileInfo
channel string
files []os.FileInfo
f os.FileInfo
channel string
stamp, _ = time.Parse("2006-01-02T15:04:05MST", LatestImageBreackage)
)
local = make(map[string]semver.Versions, 0)
for _, channel = range DefaultChannels {
Expand All @@ -100,11 +102,20 @@ func localImages() (local map[string]semver.Versions, err error) {
var v semver.Versions
for _, f = range files {
if f.IsDir() {
var s semver.Version
if s, err = semver.Make(f.Name()); err != nil {
return
if f.ModTime().After(stamp) {
var s semver.Version
if s, err = semver.Make(f.Name()); err != nil {
return
}
v = append(v, s)
} else {
// force rebuild if local image assembled before last time
// we changed its expcted format
if err = os.RemoveAll(filepath.Join(engine.imageDir,
channel, f.Name())); err != nil {
return
}
}
v = append(v, s)
}
}
semver.Sort(v)
Expand Down

0 comments on commit 0eb0dc4

Please sign in to comment.