Skip to content

Commit

Permalink
platform/azure: Support "latest" image version
Browse files Browse the repository at this point in the history
This is only used when running kola spawn with marketplace images. This
matches what azure-cli does.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
  • Loading branch information
jepio committed Sep 27, 2023
1 parent 07eea8c commit 9b7be1a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions platform/api/azure/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ func (a *API) getVMParameters(name, userdata, sshkey, storageAccountURI string,
Sku: &a.Opts.Sku,
Version: &a.Opts.Version,
}
if a.Opts.Version == "latest" {
var top int32 = 1
list, err := a.vmImgClient.List(context.TODO(), a.Opts.Location, a.Opts.Publisher, a.Opts.Offer, a.Opts.Sku, "", &top, "name desc")
if err != nil {
plog.Warningf("failed to get image list: %w; continuing", err)

Check failure on line 78 in platform/api/azure/instance.go

View workflow job for this annotation

GitHub Actions / Build

(*github.com/coreos/pkg/capnslog.PackageLogger).Warningf does not support error-wrapping directive %w
} else if list.Value == nil || (*list.Value)[0].Name == nil {
plog.Warningf("no images found; continuing")
} else {
a.Opts.Version = *(*list.Value)[0].Name
}
}
// lookup plan information for image
imgInfo, err := a.vmImgClient.Get(context.TODO(), a.Opts.Location, *imgRef.Publisher, *imgRef.Offer, *imgRef.Sku, *imgRef.Version)
if err == nil && imgInfo.Plan != nil {
Expand Down

0 comments on commit 9b7be1a

Please sign in to comment.