Skip to content

Commit

Permalink
Fix SecurityGroupClient.ListNetworkSecurityGroups() (#1980)
Browse files Browse the repository at this point in the history
The unmarshalling code didn't account for the payload being wrapped in a
NetworkSecurityGroups element; this has been fixed.
  • Loading branch information
jhendrixMSFT authored Jun 6, 2018
1 parent 18c8bc3 commit b3aa633
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions services/classic/management/networksecuritygroup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,20 @@ func (sg SecurityGroupClient) GetNetworkSecurityGroup(name string) (SecurityGrou
//
// https://msdn.microsoft.com/en-us/library/azure/dn913815.aspx
func (sg SecurityGroupClient) ListNetworkSecurityGroups() (SecurityGroupList, error) {
var securityGroups SecurityGroupList
// the list of NetworkSecurityGroup items is wrapped in a NetworkSecurityGroups
// element so we need an outer struct representing this element.
type NetworkSecurityGroups struct {
SecurityGroupList SecurityGroupList `xml:"http://schemas.microsoft.com/windowsazure NetworkSecurityGroup"`
}
var securityGroups NetworkSecurityGroups

response, err := sg.client.SendAzureGetRequest(listSecurityGroupsURL)
if err != nil {
return securityGroups, err
return securityGroups.SecurityGroupList, err
}

err = xml.Unmarshal(response, &securityGroups)
return securityGroups, err
return securityGroups.SecurityGroupList, err
}

// AddNetworkSecurityToSubnet associates the network security group with
Expand Down

0 comments on commit b3aa633

Please sign in to comment.