diff --git a/internal/cluster/cluster_operations.go b/internal/cluster/cluster_operations.go index 8d1f417..6f3b8ad 100644 --- a/internal/cluster/cluster_operations.go +++ b/internal/cluster/cluster_operations.go @@ -379,6 +379,7 @@ func FlattenCluster(ctx context.Context, clusterObj *models.Cluster, apiClient * if err != nil { return nil, err } + result["host"] = flattenedHostSpecs return &result, nil @@ -400,15 +401,9 @@ func ImportCluster(ctx context.Context, data *schema.ResourceData, apiClient *cl _ = data.Set("is_default", clusterObj.IsDefault) _ = data.Set("is_stretched", clusterObj.IsStretched) flattenedVdsSpecs := getFlattenedVdsSpecsForRefs(clusterObj.VdsSpecs) - if err != nil { - return nil, err - } _ = data.Set("vds", flattenedVdsSpecs) flattenedHostSpecs, err := getFlattenedHostSpecsForRefs(ctx, clusterObj.Hosts, apiClient) - if err != nil { - return nil, err - } _ = data.Set("host", flattenedHostSpecs) //get all domains and find our cluster to set the "domain_id" attribute, because diff --git a/internal/provider/data_source_cluster_test.go b/internal/provider/data_source_cluster_test.go index add97ab..bbd2386 100644 --- a/internal/provider/data_source_cluster_test.go +++ b/internal/provider/data_source_cluster_test.go @@ -29,6 +29,7 @@ func TestAccDataSourceVcfCluster(t *testing.T) { resource.TestCheckResourceAttrSet("data.vcf_cluster.cluster1", "primary_datastore_type"), resource.TestCheckResourceAttrSet("data.vcf_cluster.cluster1", "is_default"), resource.TestCheckResourceAttrSet("data.vcf_cluster.cluster1", "is_stretched"), + resource.TestCheckResourceAttrSet("data.vcf_cluster.cluster1", "vds"), resource.TestCheckResourceAttrSet("data.vcf_cluster.cluster1", "host.0.id"), resource.TestCheckResourceAttrSet("data.vcf_cluster.cluster1", "host.0.host_name"), resource.TestCheckResourceAttrSet("data.vcf_cluster.cluster1", "host.0.ip_address"), diff --git a/internal/provider/resource_cluster_test.go b/internal/provider/resource_cluster_test.go index 1886e9d..e96e42a 100644 --- a/internal/provider/resource_cluster_test.go +++ b/internal/provider/resource_cluster_test.go @@ -46,6 +46,7 @@ func TestAccResourceVcfClusterCreate(t *testing.T) { resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "primary_datastore_type"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "is_default"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "is_stretched"), + resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "vds"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.0.id"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.1.id"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.2.id"), @@ -117,6 +118,7 @@ func TestAccResourceVcfClusterFull(t *testing.T) { resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "primary_datastore_type"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "is_default"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "is_stretched"), + resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "vds"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.0.id"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.1.id"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.2.id"), @@ -152,6 +154,7 @@ func TestAccResourceVcfClusterFull(t *testing.T) { resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "primary_datastore_type"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "is_default"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "is_stretched"), + resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "vds"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.0.id"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.1.id"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.2.id"), @@ -181,6 +184,7 @@ func TestAccResourceVcfClusterFull(t *testing.T) { resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "primary_datastore_type"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "is_default"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "is_stretched"), + resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "vds"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.0.id"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.1.id"), resource.TestCheckResourceAttrSet("vcf_cluster.cluster1", "host.2.id"),