Skip to content

Commit

Permalink
tests(e2e): Return 0.0.0 as latest image version if none (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielNagy authored Oct 30, 2023
2 parents b41372b + a42f08e commit 6e6f454
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions e2e/internal/az/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,29 @@ func (i Image) isGen2Image() bool {
}

// LatestImageVersion returns the latest image version for the given image definition.
// If no version exists, "0.0.0" is returned.
func LatestImageVersion(ctx context.Context, imageDefinition string) (string, error) {
latestVersion := "0.0.0"

out, _, err := RunCommand(ctx, "sig", "image-version", "list",
"--resource-group", "AD",
"--gallery-name", "AD",
"--gallery-image-definition", imageDefinition,
)
if err != nil {
return "", err
return latestVersion, err
}

var versions []imageVersion
if err := json.Unmarshal(out, &versions); err != nil {
return "", err
return latestVersion, err
}
if len(versions) == 0 {
return "", nil
return latestVersion, nil
}

log.Debugf("Found %d image versions: %s", len(versions), versions)

latestVersion := "0.0.0"
for _, v := range versions {
if natural.Less(latestVersion, v.Version) {
latestVersion = v.Version
Expand Down

0 comments on commit 6e6f454

Please sign in to comment.