Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(e2e): Return 0.0.0 as latest image version if none #829

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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