Skip to content

Commit

Permalink
Use more heuristic approach to find the intended image name
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheEvilOne committed Mar 25, 2022
1 parent 2d3d34e commit 31bf9d6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/ionos/apis/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ func FindMachineImageName(ctx context.Context, client *ionossdk.APIClient, zone,
customImageNameVariant = fmt.Sprintf("%s-%s", name, version)
}

defaultImageNameVariant := fmt.Sprintf("%s-%s.qcow2", name, version)
defaultImageNameVariantWithCloudInit := fmt.Sprintf("%s-%s-cloud-init.qcow2", name, version)

defaultImageNameVariant := fmt.Sprintf("%s-%s", name, version)
location := strings.Replace(zone, "-", "/", 1)

for _, image := range *images.Items {
Expand All @@ -56,7 +54,7 @@ func FindMachineImageName(ctx context.Context, client *ionossdk.APIClient, zone,
continue
} else if (!image.Properties.HasCloudInit() || "NONE" == *image.Properties.CloudInit) {
continue
} else if customImageNameVariant != imageName && defaultImageNameVariant != imageName && defaultImageNameVariantWithCloudInit != imageName {
} else if customImageNameVariant != imageName && !strings.HasPrefix(imageName, defaultImageNameVariant) {
continue
}

Expand Down

0 comments on commit 31bf9d6

Please sign in to comment.