diff --git a/management/virtualmachineimage/client.go b/management/virtualmachineimage/client.go index 13d21b0f65..5bd304a292 100644 --- a/management/virtualmachineimage/client.go +++ b/management/virtualmachineimage/client.go @@ -19,17 +19,15 @@ func NewClient(client management.Client) Client { return Client{client} } -func (c Client) GetImageList() ([]VMImage, error) { - imageList := vmImageList{} +func (c Client) ListVirtualMachineImages() (ListVirtualMachineImagesResponse, error) { + var imageList ListVirtualMachineImagesResponse response, err := c.SendAzureGetRequest(azureImageListURL) if err != nil { - return imageList.VMImages, err + return imageList, err } - err = xml.Unmarshal(response, &imageList) - - return imageList.VMImages, err + return imageList, err } func (c Client) Capture(cloudServiceName, deploymentName, roleName string, diff --git a/management/virtualmachineimage/entities.go b/management/virtualmachineimage/entities.go index cafffcb869..9f3e874af3 100644 --- a/management/virtualmachineimage/entities.go +++ b/management/virtualmachineimage/entities.go @@ -12,7 +12,7 @@ type Client struct { management.Client } -type vmImageList struct { +type ListVirtualMachineImagesResponse struct { XMLName xml.Name `xml:"VMImages"` Xmlns string `xml:"xmlns,attr"` VMImages []VMImage `xml:"VMImage"` diff --git a/management/vmutils/integration_test.go b/management/vmutils/integration_test.go index c30b321ad3..c0f170c3da 100644 --- a/management/vmutils/integration_test.go +++ b/management/vmutils/integration_test.go @@ -38,8 +38,8 @@ func TestDeployPlatformImage(t *testing.T) { func TestVMImageList(t *testing.T) { client := testutils.GetTestClient(t) vmic := vmimage.NewClient(client) - il, _ := vmic.GetImageList() - for _, im := range il { + il, _ := vmic.ListVirtualMachineImages() + for _, im := range il.VMImages { t.Logf("%s -%s", im.Name, im.Description) } } @@ -297,12 +297,12 @@ func GetVMImage( client management.Client, filter func(vmimage.VMImage) bool) vmimage.VMImage { t.Log("Selecting VM image") - allimages, err := vmimage.NewClient(client).GetImageList() + allimages, err := vmimage.NewClient(client).ListVirtualMachineImages() if err != nil { t.Fatal(err) } filtered := []vmimage.VMImage{} - for _, im := range allimages { + for _, im := range allimages.VMImages { if filter(im) { filtered = append(filtered, im) }