Skip to content

Commit

Permalink
Merge pull request #2 from crusoecloud/firewall-star
Browse files Browse the repository at this point in the history
Support star for Firewall Rule Ports
  • Loading branch information
agutierrez8 authored Jun 15, 2023
2 parents efd3d92 + fdfe78a commit 0ad5f0b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/firewall_rule/firewall_rule_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ func (r *firewallRuleResource) Create(ctx context.Context, req resource.CreateRe
return
}

sourcePortsStr := strings.ReplaceAll(plan.SourcePorts.ValueString(), "*", "1-65535")
destPortsStr := strings.ReplaceAll(plan.DestinationPorts.ValueString(), "*", "1-65535")

dataResp, httpResp, err := r.client.VPCFirewallRulesApi.CreateVPCFirewallRule(ctx, swagger.VpcFirewallRulesPostRequest{
RoleId: roleID,
VpcNetworkId: plan.Network.ValueString(),
Expand All @@ -133,9 +136,9 @@ func (r *firewallRuleResource) Create(ctx context.Context, req resource.CreateRe
Protocols: stringToSlice(plan.Protocols.ValueString(), ","),
Direction: plan.Direction.ValueString(),
Sources: []swagger.FirewallRuleObject{toFirewallRuleObject(plan.Source.ValueString())},
SourcePorts: stringToSlice(plan.SourcePorts.ValueString(), ","),
SourcePorts: stringToSlice(sourcePortsStr, ","),
Destinations: []swagger.FirewallRuleObject{toFirewallRuleObject(plan.Destination.ValueString())},
DestinationPorts: stringToSlice(plan.DestinationPorts.ValueString(), ","),
DestinationPorts: stringToSlice(destPortsStr, ","),
})
if err != nil {
resp.Diagnostics.AddError("Failed to create firewall rule",
Expand Down

0 comments on commit 0ad5f0b

Please sign in to comment.