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

Add import hypervisor_cluster #86

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 10 additions & 12 deletions internal/resources/hypervisorcluster/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,6 @@ func doRead(
return
}

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

return
}

(*dataP).HciClusterUuid = types.StringValue(*(getResp.GetHciClusterUuid()))

if getResp.GetName() == nil {
Expand Down Expand Up @@ -220,7 +209,16 @@ func doRead(
return
}

(*dataP).AppInfo.Vmware = vmwareValueObj
m = map[string]attr.Value{
"vmware": vmwareValueObj,
}

appInfoValue, diags := NewAppInfoValue(AppInfoValue{}.AttributeTypes(ctx), m)
(*diagsP).Append(diags...)
if (*diagsP).HasError() {
return
}
(*dataP).AppInfo = appInfoValue
}

func doCreate(
Expand Down
16 changes: 16 additions & 0 deletions test/hypervisorcluster/hypervisorcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ func TestAccHypervisorclusterResource(t *testing.T) {
testAccCheckResourceDestroyed("hpegl_pc_hypervisor_cluster.test"),
),
},
{
// Import
Check: checkFn,
Config: config1,
ImportState: true,
ResourceName: "hpegl_pc_hypervisor_cluster.test",
ImportStateId: "298a299e-78f5-5acb-86ce-4e9fdc290ab7",
ImportStatePersist: true,
},
{
// Check post import state matches the resource config
// e.g. verfies 'name' in state matches 'name' in config
Config: config1,
Check: checkFn,
ExpectNonEmptyPlan: false,
},
},
})
}