Skip to content

Commit 42f99ce

Browse files
authored
Merge pull request #610 from ovh/dev/aamstutz/fix-608
fix: Use correct types for API response of resource/datasource ovh_ip_firewall_rule
2 parents 39768c5 + d68a6c7 commit 42f99ce

7 files changed

+155
-24
lines changed

Diff for: ovh/data_ip_firewall_rule.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (d *ipFirewallRuleDataSource) Schema(ctx context.Context, req datasource.Sc
4444
}
4545

4646
func (d *ipFirewallRuleDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
47-
var data IpFirewallRuleModel
47+
var data IpFirewallRuleDataResponseModel
4848

4949
// Read Terraform configuration data into the model
5050
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)

Diff for: ovh/data_ip_firewall_rule_gen.go

+21-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ovh/data_ip_firewall_rule_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func TestAccIPFirewallRule_data(t *testing.T) {
2929
protocol = "tcp"
3030
sequence = 0
3131
tcp_option = "established"
32-
fragments = true
32+
destination_port = 22
33+
source_port = 44
3334
}
3435
3536
data "ovh_ip_firewall_rule" "rule_data" {
@@ -56,6 +57,10 @@ func TestAccIPFirewallRule_data(t *testing.T) {
5657
"data.ovh_ip_firewall_rule.rule_data", "source", "any"),
5758
resource.TestCheckResourceAttr(
5859
"data.ovh_ip_firewall_rule.rule_data", "tcp_option", "established"),
60+
resource.TestCheckResourceAttr(
61+
"data.ovh_ip_firewall_rule.rule_data", "destination_port", "eq 22"),
62+
resource.TestCheckResourceAttr(
63+
"data.ovh_ip_firewall_rule.rule_data", "source_port", "eq 44"),
5964
),
6065
},
6166
},

Diff for: ovh/resource_ip_firewall_rule.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ func (d *ipFirewallRuleResource) Schema(ctx context.Context, req resource.Schema
4848
}
4949

5050
func (r *ipFirewallRuleResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
51-
var data, responseData IpFirewallRuleModel
51+
var (
52+
data IpFirewallRuleModel
53+
responseData IpFirewallRuleResponseModel
54+
)
5255

5356
// Read Terraform plan data into the model
5457
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
@@ -100,7 +103,10 @@ func (r *ipFirewallRuleResource) Create(ctx context.Context, req resource.Create
100103
}
101104

102105
func (r *ipFirewallRuleResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
103-
var data, responseData IpFirewallRuleModel
106+
var (
107+
data IpFirewallRuleModel
108+
responseData IpFirewallRuleResponseModel
109+
)
104110

105111
// Read Terraform prior state data into the model
106112
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)

Diff for: ovh/resource_ip_firewall_rule_gen.go

+106-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ovh/resource_ip_firewall_rule_test.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func TestAccIPFirewallRule_basic(t *testing.T) {
2929
protocol = "tcp"
3030
sequence = 0
3131
tcp_option = "established"
32-
fragments = true
32+
destination_port = 22
33+
source_port = 44
3334
}
3435
`, ip, ip)
3536

@@ -50,6 +51,14 @@ func TestAccIPFirewallRule_basic(t *testing.T) {
5051
"ovh_ip_firewall_rule.rule", "source", "any"),
5152
resource.TestCheckResourceAttr(
5253
"ovh_ip_firewall_rule.rule", "tcp_option", "established"),
54+
resource.TestCheckResourceAttr(
55+
"ovh_ip_firewall_rule.rule", "destination_port", "22"),
56+
resource.TestCheckResourceAttr(
57+
"ovh_ip_firewall_rule.rule", "destination_port_desc", "eq 22"),
58+
resource.TestCheckResourceAttr(
59+
"ovh_ip_firewall_rule.rule", "source_port", "44"),
60+
resource.TestCheckResourceAttr(
61+
"ovh_ip_firewall_rule.rule", "source_port_desc", "eq 44"),
5362
),
5463
},
5564
},

Diff for: website/docs/r/ip_firewall_rule.html.markdown

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
subcategory : "Additional IP"
33
---
44

5-
# ovh_ip_firewall
5+
# ovh_ip_firewall_rule
66

77
Use this resource to manage a rule on an IP firewall.
88

@@ -39,10 +39,12 @@ resource "ovh_ip_firewall_rule" "myfirewallrule" {
3939
* `creation_date` - Creation date of the rule
4040
* `destination` - Destination IP for your rule
4141
* `destination_port` - Destination port for your rule. Only with TCP/UDP protocol
42+
* `destination_port_desc` - String description of field `destination_port`
4243
* `fragments` - Fragments option
4344
* `protocol` - Possible values for protocol (ah|esp|gre|icmp|ipv4|tcp|udp)
4445
* `rule` - Description of the rule
4546
* `sequence` - Rule position in the rules array
4647
* `source` - IPv4 CIDR notation (e.g., 192.0.2.0/24)
4748
* `source_port` - Source port for your rule. Only with TCP/UDP protocol
49+
* `source_port_desc` - String description of field `source_port`
4850
* `tcp_option` - TCP option on your rule (syn|established)

0 commit comments

Comments
 (0)