in cmd/utils/vmss.go [53:77]
func ParseVMSSResourceID(id string, vm *VirtualMachineScaleSetVM) error {
const expectedItems int = 5
// This allows us to make resource ID (--id) option not case sentitive
id = strings.ToLower(id)
// Required because fmt.Sscanf expects space-separated values
idWithSpaces := strings.TrimSpace(strings.Replace(id, "/", " ", -1))
// We don't need the provider but fmt.Sscanf does not support "%*s" operator
// to read but prevent conversion. Therefore, read it and don't use it.
var provider string
n, err := fmt.Sscanf(idWithSpaces, "subscriptions %s resourcegroups %s providers %s virtualmachinescalesets %s virtualmachines %s",
&vm.SubscriptionID, &vm.NodeResourceGroup, &provider, &vm.VMScaleSet, &vm.InstanceID)
if err != nil {
return fmt.Errorf("error parsing provider ID %q: %w", id, err)
}
if n != expectedItems {
return fmt.Errorf("%d values retrieved while expecting %d when parsing id %s",
n, expectedItems, id)
}
return nil
}