Skip to content

Commit

Permalink
commonids: updating Virtual Network and Subnet to use the new errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed May 9, 2023
1 parent fbe78f7 commit d644eaa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions resourcemanager/commonids/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ func ParseSubnetID(input string) (*SubnetId, error) {
id := SubnetId{}

if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok {
return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed)
}

if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok {
return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed)
}

if id.VirtualNetworkName, ok = parsed.Parsed["virtualNetworkName"]; !ok {
return nil, fmt.Errorf("the segment 'virtualNetworkName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkName", *parsed)
}

if id.SubnetName, ok = parsed.Parsed["subnetName"]; !ok {
return nil, fmt.Errorf("the segment 'subnetName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "subnetName", *parsed)
}

return &id, nil
Expand All @@ -73,19 +73,19 @@ func ParseSubnetIDInsensitively(input string) (*SubnetId, error) {
id := SubnetId{}

if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok {
return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed)
}

if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok {
return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed)
}

if id.VirtualNetworkName, ok = parsed.Parsed["virtualNetworkName"]; !ok {
return nil, fmt.Errorf("the segment 'virtualNetworkName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkName", *parsed)
}

if id.SubnetName, ok = parsed.Parsed["subnetName"]; !ok {
return nil, fmt.Errorf("the segment 'subnetName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "subnetName", *parsed)
}

return &id, nil
Expand Down
12 changes: 6 additions & 6 deletions resourcemanager/commonids/virtual_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ func ParseVirtualNetworkID(input string) (*VirtualNetworkId, error) {
id := VirtualNetworkId{}

if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok {
return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed)
}

if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok {
return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed)
}

if id.VirtualNetworkName, ok = parsed.Parsed["virtualNetworkName"]; !ok {
return nil, fmt.Errorf("the segment 'virtualNetworkName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkName", *parsed)
}

return &id, nil
Expand All @@ -67,15 +67,15 @@ func ParseVirtualNetworkIDInsensitively(input string) (*VirtualNetworkId, error)
id := VirtualNetworkId{}

if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok {
return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed)
}

if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok {
return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed)
}

if id.VirtualNetworkName, ok = parsed.Parsed["virtualNetworkName"]; !ok {
return nil, fmt.Errorf("the segment 'virtualNetworkName' was not found in the resource id %q", input)
return nil, resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkName", *parsed)
}

return &id, nil
Expand Down

0 comments on commit d644eaa

Please sign in to comment.