Skip to content

Commit

Permalink
Merge branch 'master' into cidr-edit
Browse files Browse the repository at this point in the history
  • Loading branch information
uzaxirr committed Jun 27, 2024
2 parents dd943d6 + 55973e3 commit ffa98c9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions civo/network/resource_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf
return err
}
d.SetId(network.ID)

// Create a default firewall for the network
log.Printf("[INFO] Creating default firewall for the network %s", d.Get("label").(string))
err = createDefaultFirewall(apiClient, network.ID, network.Label)
if err != nil {
return err
}

return nil
}, 10*time.Second, 2*time.Minute)

Expand Down Expand Up @@ -262,9 +270,25 @@ 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")
}

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

Check failure on line 280 in civo/network/resource_network.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

expected '(', found createDefaultFirewall (and 1 more errors)

Check failure on line 280 in civo/network/resource_network.go

View workflow job for this annotation

GitHub Actions / build (1.20.x, ubuntu-latest)

syntax error: unexpected createDefaultFirewall, expected (

Check failure on line 280 in civo/network/resource_network.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

expected '(', found createDefaultFirewall (and 1 more errors)

firewallConfig := civogo.FirewallConfig{
Name: fmt.Sprintf("%s-default", networkName),
NetworkID: networkID,
Region: apiClient.Region,
}

// Create the default firewall
_, err := apiClient.NewFirewall(&firewallConfig)
if err != nil {
return err
}
return nil
}

0 comments on commit ffa98c9

Please sign in to comment.