From 8fbaf1a557cbcce49f8c53449c485583ce861403 Mon Sep 17 00:00:00 2001 From: Guest OS Images Date: Sun, 7 Jul 2024 22:46:38 -0700 Subject: [PATCH] Add support for computeBeta API in cloud_image_tests. This is needed to run the cvm test suite on confidential VMs since currently TDX only runs on beta version. PiperOrigin-RevId: 650126941 --- compute/compute.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compute/compute.go b/compute/compute.go index f50909a6..7c1694a6 100644 --- a/compute/compute.go +++ b/compute/compute.go @@ -80,6 +80,7 @@ type Client interface { GetImageAlpha(project, name string) (*computeAlpha.Image, error) GetImageBeta(project, name string) (*computeBeta.Image, error) GetImageFromFamily(project, family string) (*compute.Image, error) + GetImageFromFamilyBeta(project, family string) (*computeBeta.Image, error) GetLicense(project, name string) (*compute.License, error) GetNetwork(project, name string) (*compute.Network, error) GetRegion(project, region string) (*compute.Region, error) @@ -1560,6 +1561,15 @@ func (c *client) GetImageFromFamily(project, family string) (*compute.Image, err return i, err } +// GetImageFromFamilyBeta gets a GCE Image from an image family using Beta API. +func (c *client) GetImageFromFamilyBeta(project, family string) (*computeBeta.Image, error) { + i, err := c.rawBeta.Images.GetFromFamily(project, family).Do() + if shouldRetryWithWait(c.hc.Transport, err, 2) { + return c.rawBeta.Images.GetFromFamily(project, family).Do() + } + return i, err +} + // ListImages gets a list of GCE Images. func (c *client) ListImages(project string, opts ...ListCallOption) ([]*compute.Image, error) { var is []*compute.Image