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): Null image version check improvements #830

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion e2e/cmd/build_base_image/00_check_vm_image/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func action(ctx context.Context, _ *command.Command) error {
// - Z: patch version, incremented for consecutive builds of the same minor version, starts at 0

// Handle case where we have no custom image at all
if latestCustomImageVersion == "0.0.0" || force {
if latestCustomImageVersion == az.NullImageVersion || force {
fmt.Println(latest.URN)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/cmd/build_base_image/02_create_vm_template/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func action(ctx context.Context, cmd *command.Command) error {
}()

// If the version is empty, we need to create the image definition
if latestImageVersion == "" {
if latestImageVersion == az.NullImageVersion {
log.Infof("Creating image definition %q", imageDefinition)
_, _, err := az.RunCommand(ctx, "sig", "image-definition", "create",
"--resource-group", "AD",
Expand Down
5 changes: 4 additions & 1 deletion e2e/internal/az/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
"golang.org/x/exp/slices"
)

// NullImageVersion is the version returned when no image version is found.
const NullImageVersion = "0.0.0"

// Image contains information about an Azure image.
type Image struct {
Architecture string `json:"architecture"`
Expand Down Expand Up @@ -104,7 +107,7 @@ 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"
latestVersion := NullImageVersion

out, _, err := RunCommand(ctx, "sig", "image-version", "list",
"--resource-group", "AD",
Expand Down