diff --git a/internal/providers/pluginfw/resources/cluster/data_cluster.go b/internal/providers/pluginfw/resources/cluster/data_cluster.go index b497d0e8f2..8d0499ccb8 100644 --- a/internal/providers/pluginfw/resources/cluster/data_cluster.go +++ b/internal/providers/pluginfw/resources/cluster/data_cluster.go @@ -32,9 +32,9 @@ type ClusterDataSource struct { } type ClusterInfo struct { - ClusterId types.String `tfsdk:"cluster_id" tf:"optional,computed"` - Name types.String `tfsdk:"cluster_name" tf:"optional,computed"` - ClusterInfo *compute_tf.ClusterDetails `tfsdk:"cluster_info" tf:"optional,computed"` + ClusterId types.String `tfsdk:"cluster_id" tf:"optional,computed"` + Name types.String `tfsdk:"cluster_name" tf:"optional,computed"` + ClusterInfo []compute_tf.ClusterDetails `tfsdk:"cluster_info" tf:"optional,computed"` } func (d *ClusterDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { @@ -109,7 +109,7 @@ func (d *ClusterDataSource) Read(ctx context.Context, req datasource.ReadRequest if resp.Diagnostics.HasError() { return } - clusterInfo.ClusterInfo = &namedClusters[0] + clusterInfo.ClusterInfo = namedClusters[0:1] } else if clusterId != "" { cluster, err := w.Clusters.GetByClusterId(ctx, clusterId) if err != nil { @@ -124,12 +124,12 @@ func (d *ClusterDataSource) Read(ctx context.Context, req datasource.ReadRequest if resp.Diagnostics.HasError() { return } - clusterInfo.ClusterInfo = &clusterDetails + clusterInfo.ClusterInfo = []compute_tf.ClusterDetails{clusterDetails} } else { resp.Diagnostics.AddError("you need to specify either `cluster_name` or `cluster_id`", "") return } - clusterInfo.ClusterId = clusterInfo.ClusterInfo.ClusterId - clusterInfo.Name = clusterInfo.ClusterInfo.ClusterName + clusterInfo.ClusterId = clusterInfo.ClusterInfo[0].ClusterId + clusterInfo.Name = clusterInfo.ClusterInfo[0].ClusterName resp.Diagnostics.Append(resp.State.Set(ctx, clusterInfo)...) }