Skip to content

Commit

Permalink
Make CIDR immutable for network resource (#240)
Browse files Browse the repository at this point in the history
* make CIDR immutable for network resource
  • Loading branch information
uzaxirr authored Jul 9, 2024
1 parent c225818 commit 11d10f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion civo/network/resource_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func ResourceNetwork() *schema.Resource {
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
CustomizeDiff: customizeDiffNetwork,
}
}

Expand Down Expand Up @@ -279,6 +280,13 @@ func expandStringList(input interface{}) []string {
return result
}

func customizeDiffNetwork(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error {
if d.Id() != "" && d.HasChange("cidr_v4") {
return fmt.Errorf("the 'cidr_v4' field is immutable")
}
return nil
}

// createDefaultFirewall function to create a default firewall
func createDefaultFirewall(apiClient *civogo.Client, networkID string, networkName string) error {

Expand All @@ -293,6 +301,5 @@ func createDefaultFirewall(apiClient *civogo.Client, networkID string, networkNa
if err != nil {
return err
}

return nil
}

0 comments on commit 11d10f8

Please sign in to comment.