Fix cluster network mapping (#375)
* Make cluster network computed * Replace computed with better mapping * Fix comment * Update unit test§
This commit is contained in:
parent
35b10c602b
commit
ecaf622f55
2 changed files with 16 additions and 7 deletions
|
|
@ -1486,6 +1486,17 @@ func mapNetwork(cl *ske.Cluster, m *Model) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the network field is not provided, the SKE API returns an empty object.
|
||||||
|
// If we parse that object into the terraform model, it will produce an inconsistent result after apply error
|
||||||
|
|
||||||
|
emptyNetwork := &ske.V1Network{}
|
||||||
|
if *cl.Network == *emptyNetwork && m.Network.IsNull() {
|
||||||
|
if m.Network.Attributes() == nil {
|
||||||
|
m.Network = types.ObjectNull(networkTypes)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
id := types.StringNull()
|
id := types.StringNull()
|
||||||
if cl.Network.Id != nil {
|
if cl.Network.Id != nil {
|
||||||
id = types.StringValue(*cl.Network.Id)
|
id = types.StringValue(*cl.Network.Id)
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,7 @@ func TestMapFields(t *testing.T) {
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nil_network_id",
|
"empty_network",
|
||||||
types.ObjectNull(extensionsTypes),
|
types.ObjectNull(extensionsTypes),
|
||||||
&ske.Cluster{
|
&ske.Cluster{
|
||||||
Name: utils.Ptr("name"),
|
Name: utils.Ptr("name"),
|
||||||
|
|
@ -245,12 +245,10 @@ func TestMapFields(t *testing.T) {
|
||||||
AllowPrivilegedContainers: types.BoolNull(),
|
AllowPrivilegedContainers: types.BoolNull(),
|
||||||
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
|
NodePools: types.ListNull(types.ObjectType{AttrTypes: nodePoolTypes}),
|
||||||
Maintenance: types.ObjectNull(maintenanceTypes),
|
Maintenance: types.ObjectNull(maintenanceTypes),
|
||||||
Network: types.ObjectValueMust(networkTypes, map[string]attr.Value{
|
Network: types.ObjectNull(networkTypes),
|
||||||
"id": types.StringNull(),
|
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
|
||||||
}),
|
Extensions: types.ObjectNull(extensionsTypes),
|
||||||
Hibernations: types.ListNull(types.ObjectType{AttrTypes: hibernationTypes}),
|
KubeConfig: types.StringNull(),
|
||||||
Extensions: types.ObjectNull(extensionsTypes),
|
|
||||||
KubeConfig: types.StringNull(),
|
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue