File tree Expand file tree Collapse file tree
stackit/internal/services/ske/cluster Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1486,6 +1486,17 @@ func mapNetwork(cl *ske.Cluster, m *Model) error {
14861486 return nil
14871487 }
14881488
1489+ // If the network field is not provided, the SKE API returns an empty object.
1490+ // If we parse that object into the terraform model, it will produce an inconsistent result after apply error
1491+
1492+ emptyNetwork := & ske.V1Network {}
1493+ if * cl .Network == * emptyNetwork && m .Network .IsNull () {
1494+ if m .Network .Attributes () == nil {
1495+ m .Network = types .ObjectNull (networkTypes )
1496+ }
1497+ return nil
1498+ }
1499+
14891500 id := types .StringNull ()
14901501 if cl .Network .Id != nil {
14911502 id = types .StringValue (* cl .Network .Id )
Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ func TestMapFields(t *testing.T) {
231231 true ,
232232 },
233233 {
234- "nil_network_id " ,
234+ "empty_network " ,
235235 types .ObjectNull (extensionsTypes ),
236236 & ske.Cluster {
237237 Name : utils .Ptr ("name" ),
@@ -245,12 +245,10 @@ func TestMapFields(t *testing.T) {
245245 AllowPrivilegedContainers : types .BoolNull (),
246246 NodePools : types .ListNull (types.ObjectType {AttrTypes : nodePoolTypes }),
247247 Maintenance : types .ObjectNull (maintenanceTypes ),
248- Network : types .ObjectValueMust (networkTypes , map [string ]attr.Value {
249- "id" : types .StringNull (),
250- }),
251- Hibernations : types .ListNull (types.ObjectType {AttrTypes : hibernationTypes }),
252- Extensions : types .ObjectNull (extensionsTypes ),
253- KubeConfig : types .StringNull (),
248+ Network : types .ObjectNull (networkTypes ),
249+ Hibernations : types .ListNull (types.ObjectType {AttrTypes : hibernationTypes }),
250+ Extensions : types .ObjectNull (extensionsTypes ),
251+ KubeConfig : types .StringNull (),
254252 },
255253 true ,
256254 },
You can’t perform that action at this time.
0 commit comments