mgmt/virtualmachineimage: Fix inconsistencies

More work for unifying the method signatures and eliminating
client side client logic.
This commit is contained in:
Ahmet Alp Balkan 2015-05-18 14:58:15 -07:00
Родитель 8fc04323d5
Коммит f396750758
3 изменённых файлов: 9 добавлений и 11 удалений

Просмотреть файл

@ -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,

Просмотреть файл

@ -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"`

Просмотреть файл

@ -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)
}