Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_[linux|windows]_virtual_machine - if the priority property on read is empty assume it to be Regular #6301

Merged
merged 2 commits into from
Apr 7, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,13 @@ func resourceLinuxVirtualMachineRead(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("Error setting `secret`: %+v", err)
}
}

d.Set("priority", string(props.Priority))
// Resources created with azurerm_virtual_machine have priority set to ""
// We need to treat "" as equal to "Regular" to allow migration azurerm_virtual_machine -> azurerm_linux_virtual_machine
priority := props.Priority
if priority == "" {
priority = compute.Regular
}
d.Set("priority", string(priority))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please do this by assigning the default value first, and then check if response is empty and then assign the real value if it is empty.

Suggested change
priority := props.Priority
if priority == "" {
priority = compute.Regular
}
d.Set("priority", string(priority))
priority := string(compute.Regular)
if props.Priority != "" {
priority = string(props.Priority)
}
d.Set("priority", priority)

proximityPlacementGroupId := ""
if props.ProximityPlacementGroup != nil && props.ProximityPlacementGroup.ID != nil {
proximityPlacementGroupId = *props.ProximityPlacementGroup.ID
Expand Down