Skip to content

Commit

Permalink
fixed auto_delete issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ibm committed Dec 6, 2024
1 parent 9404df3 commit df0e8ab
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ibm/service/vpc/resource_ibm_is_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func ResourceIBMISInstance() *schema.Resource {
Optional: true,
Computed: true,
DiffSuppressOnRefresh: true,
DiffSuppressFunc: flex.ApplyOnce,
DiffSuppressFunc: flex.ApplyOnlyOnce,
Description: "Indicates whether this cluster network interface will be automatically deleted when `target` is deleted.",
},
"name": &schema.Schema{
Expand Down Expand Up @@ -275,7 +275,7 @@ func ResourceIBMISInstance() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
Computed: true,
DiffSuppressFunc: flex.ApplyOnce,
DiffSuppressFunc: flex.ApplyOnlyOnce,
Description: "Indicates whether this cluster network subnet reserved IP member will be automatically deleted when either `target` is deleted, or the cluster network subnet reserved IP is unbound.",
},
"name": &schema.Schema{
Expand Down Expand Up @@ -8351,10 +8351,22 @@ func compareInterfaces(old, new map[string]interface{}) bool {

func buildCreateClusterNetworkAttachmentOptions(instanceID string, attachment map[string]interface{}) *vpcv1.CreateClusterNetworkAttachmentOptions {
networkInterface := attachment["cluster_network_interface"].([]interface{})[0].(map[string]interface{})

clusterNetworkInterface := &vpcv1.InstanceClusterNetworkAttachmentPrototypeClusterNetworkInterface{}

if autoDelete, ok := networkInterface["auto_delete"].(bool); ok {
clusterNetworkInterface.AutoDelete = &autoDelete
// if autoDelete, ok := networkInterface["auto_delete"].(bool); ok {
// clusterNetworkInterface.AutoDelete = &autoDelete
// }
if autoDelete, ok := networkInterface["auto_delete"]; ok {
// Convert interface{} to bool properly
autoDeletBool := false
switch v := autoDelete.(type) {
case bool:
autoDeletBool = v
case string:
autoDeletBool = v == "true"
}
clusterNetworkInterface.AutoDelete = &autoDeletBool
}

if name, ok := networkInterface["name"].(string); ok {
Expand Down

0 comments on commit df0e8ab

Please sign in to comment.