Skip to content

Commit

Permalink
Do not hide images on machine create which are already expired (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Nov 27, 2020
1 parent c4d9143 commit ad0ad87
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
3 changes: 0 additions & 3 deletions cmd/metal-api/internal/datastore/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ func (rs *RethinkStore) getMostRecentImageFor(id string, images metal.Images) (*
if os != image.OS {
continue
}
if time.Since(image.ExpirationDate) > 0 {
continue
}
v, err := semver.NewVersion(image.Version)
if err != nil {
continue
Expand Down
10 changes: 0 additions & 10 deletions cmd/metal-api/internal/datastore/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ func TestRethinkStore_UpdateImage(t *testing.T) {
}
}
func Test_getMostRecentImageFor(t *testing.T) {
invalid := time.Now().Add(time.Hour * -1)
valid := time.Now().Add(time.Hour)
ubuntu14_1 := metal.Image{Base: metal.Base{ID: "ubuntu-14.1"}, OS: "ubuntu", Version: "14.1", ExpirationDate: valid}
ubuntu14_04 := metal.Image{Base: metal.Base{ID: "ubuntu-14.04"}, OS: "ubuntu", Version: "14.04", ExpirationDate: valid}
Expand All @@ -235,8 +234,6 @@ func Test_getMostRecentImageFor(t *testing.T) {
ubuntu20_04_20200501 := metal.Image{Base: metal.Base{ID: "ubuntu-20.04.20200501"}, OS: "ubuntu", Version: "20.04.20200501", ExpirationDate: valid}
ubuntu20_04_20200502 := metal.Image{Base: metal.Base{ID: "ubuntu-20.04.20200502"}, OS: "ubuntu", Version: "20.04.20200502", ExpirationDate: valid}
ubuntu20_04_20200603 := metal.Image{Base: metal.Base{ID: "ubuntu-20.04.20200603"}, OS: "ubuntu", Version: "20.04.20200603", ExpirationDate: valid}
ubuntu20_04_20200602 := metal.Image{Base: metal.Base{ID: "ubuntu-20.10.20200602"}, OS: "ubuntu", Version: "20.10.20200602", ExpirationDate: valid}
ubuntu20_10_20200603 := metal.Image{Base: metal.Base{ID: "ubuntu-20.10.20200603"}, OS: "ubuntu", Version: "20.10.20200603", ExpirationDate: invalid}

alpine3_9 := metal.Image{Base: metal.Base{ID: "alpine-3.9"}, OS: "alpine", Version: "3.9", ExpirationDate: valid}
alpine3_9_20191012 := metal.Image{Base: metal.Base{ID: "alpine-3.9.20191012"}, OS: "alpine", Version: "3.9.20191012", ExpirationDate: valid}
Expand Down Expand Up @@ -291,13 +288,6 @@ func Test_getMostRecentImageFor(t *testing.T) {
want: &alpine3_9_20191012,
wantErr: false,
},
{
name: "ubuntu with invalid",
id: "ubuntu-20.10",
images: []metal.Image{ubuntu20_04_20200602, ubuntu20_10_20200603},
want: &ubuntu20_04_20200602,
wantErr: false,
},
}
rs := &RethinkStore{}

Expand Down

0 comments on commit ad0ad87

Please sign in to comment.