From 12d004590949d939f1159751f8e796d117c98834 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 6 Dec 2023 12:19:38 +0100 Subject: [PATCH] return diags --- internal/common/cluster_node_pool.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/common/cluster_node_pool.go b/internal/common/cluster_node_pool.go index 0c8094a..0de8c68 100644 --- a/internal/common/cluster_node_pool.go +++ b/internal/common/cluster_node_pool.go @@ -80,8 +80,8 @@ func (c *ClusterNodePool) TerraformAttributesLabels() attr.Value { return types.MapValueMust(types.StringType, c.Labels.Elements()) } -func (c *ClusterNodePool) Element() attr.Value { - return types.ObjectValueMust(ClusterNodePoolAttrTypes, c.terraformAttributes()) +func (c *ClusterNodePool) Element() (attr.Value, diag.Diagnostics) { + return types.ObjectValue(ClusterNodePoolAttrTypes, c.terraformAttributes()) } type NodePoolTaint struct { @@ -136,7 +136,7 @@ func ClusterNodePoolsFrom(nodePools []*console.NodePoolFragment, configNodePools result := make(map[string]attr.Value) for _, nodePool := range nodePools { - result[nodePool.Name] = (&ClusterNodePool{ + objValue, diags := (&ClusterNodePool{ Name: types.StringValue(nodePool.Name), MinSize: types.Int64Value(nodePool.MinSize), MaxSize: types.Int64Value(nodePool.MaxSize), @@ -145,6 +145,8 @@ func ClusterNodePoolsFrom(nodePools []*console.NodePoolFragment, configNodePools Taints: clusterNodePoolTaintsFrom(nodePool, ctx, d), CloudSettings: configNodePoolsElements[nodePool.Name].CloudSettings, // Rewriting config to state to avoid unknown values. }).Element() + d.Append(diags...) + result[nodePool.Name] = objValue } mapValue, diags := types.MapValue(basetypes.ObjectType{AttrTypes: ClusterNodePoolAttrTypes}, result)