Skip to content

Commit

Permalink
Handle system id mismatch for datastore
Browse files Browse the repository at this point in the history
If the system id underpinning a datastore unexpectedly
changes, raise the following error:

```
Error: error reading datastore

  with hpegl_pc_datastore.my_datastore,
  on main.tf line 27, in resource "hpegl_pc_datastore" "my_datastore":
  27: resource "hpegl_pc_datastore" "my_datastore" {

'hciClusterUuid' mismatch: 126fd201-9e6e-5e31-9ffb-a766265b1fd3 != 326fd201-9e6e-5e31-9ffb-a766265b1fd3
```
  • Loading branch information
stuart-mclaren-hpe committed Aug 29, 2024
1 parent 2d951e0 commit 9a42f75
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions internal/resources/datastore/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,27 @@ func doRead(
return
}

if datastore.GetHciClusterUuid() == nil {
(*diagsP).AddError(
"error reading datastore",
"'hciClusterUuid' is nil",
)

return
}

systemID := (*dataP).HciClusterUuid.ValueString()
if *(datastore.GetHciClusterUuid()) != systemID {
(*diagsP).AddError(
"error reading datastore",
fmt.Sprintf("'hciClusterUuid' mismatch: %s != %s",
*(datastore.GetHciClusterUuid()), systemID,
),
)

return
}

datastoreName := datastore.GetName()
if datastoreName == nil {
(*diagsP).AddError(
Expand Down

0 comments on commit 9a42f75

Please sign in to comment.