Skip to content

Commit

Permalink
fix(baremetal): fix import server without an installed os (#1831)
Browse files Browse the repository at this point in the history
  • Loading branch information
yfodil authored Mar 10, 2023
1 parent c4c7b10 commit 240639f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scaleway/resource_baremetal_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,15 @@ func resourceScalewayBaremetalServerRead(ctx context.Context, d *schema.Resource
return diag.FromErr(err)
}

os, err := baremetalAPI.GetOS(&baremetal.GetOSRequest{
Zone: server.Zone,
OsID: server.Install.OsID,
})
if err != nil {
return diag.FromErr(err)
var os *baremetal.OS
if server.Install != nil {
os, err = baremetalAPI.GetOS(&baremetal.GetOSRequest{
Zone: server.Zone,
OsID: server.Install.OsID,
})
if err != nil {
return diag.FromErr(err)
}
}

_ = d.Set("name", server.Name)
Expand Down

0 comments on commit 240639f

Please sign in to comment.