Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CIDR immutable for network resource #240

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion civo/network/resource_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func ResourceNetwork() *schema.Resource {
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
},
CustomizeDiff: customizeDiffNetwork,
}
}

Expand Down Expand Up @@ -269,6 +270,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 @@ -283,6 +291,5 @@ func createDefaultFirewall(apiClient *civogo.Client, networkID string, networkNa
if err != nil {
return err
}

return nil
}
Loading