Skip to content

Commit

Permalink
Extract null image version to a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielNagy committed Oct 30, 2023
1 parent 6bb5e84 commit 2249f08
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
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 == "0.0.0" {
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

0 comments on commit 2249f08

Please sign in to comment.