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

fix: Use correct types for API response of resource/datasource ovh_ip_firewall_rule #610

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ovh/data_ip_firewall_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (d *ipFirewallRuleDataSource) Schema(ctx context.Context, req datasource.Sc
}

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

// Read Terraform configuration data into the model
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
Expand Down
25 changes: 21 additions & 4 deletions ovh/data_ip_firewall_rule_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion ovh/data_ip_firewall_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func TestAccIPFirewallRule_data(t *testing.T) {
protocol = "tcp"
sequence = 0
tcp_option = "established"
fragments = true
destination_port = 22
source_port = 44
}

data "ovh_ip_firewall_rule" "rule_data" {
Expand All @@ -56,6 +57,10 @@ func TestAccIPFirewallRule_data(t *testing.T) {
"data.ovh_ip_firewall_rule.rule_data", "source", "any"),
resource.TestCheckResourceAttr(
"data.ovh_ip_firewall_rule.rule_data", "tcp_option", "established"),
resource.TestCheckResourceAttr(
"data.ovh_ip_firewall_rule.rule_data", "destination_port", "eq 22"),
resource.TestCheckResourceAttr(
"data.ovh_ip_firewall_rule.rule_data", "source_port", "eq 44"),
),
},
},
Expand Down
10 changes: 8 additions & 2 deletions ovh/resource_ip_firewall_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func (d *ipFirewallRuleResource) Schema(ctx context.Context, req resource.Schema
}

func (r *ipFirewallRuleResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var data, responseData IpFirewallRuleModel
var (
data IpFirewallRuleModel
responseData IpFirewallRuleResponseModel
)

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

func (r *ipFirewallRuleResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
var data, responseData IpFirewallRuleModel
var (
data IpFirewallRuleModel
responseData IpFirewallRuleResponseModel
)

// Read Terraform prior state data into the model
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
Expand Down
120 changes: 106 additions & 14 deletions ovh/resource_ip_firewall_rule_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion ovh/resource_ip_firewall_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func TestAccIPFirewallRule_basic(t *testing.T) {
protocol = "tcp"
sequence = 0
tcp_option = "established"
fragments = true
destination_port = 22
source_port = 44
}
`, ip, ip)

Expand All @@ -50,6 +51,14 @@ func TestAccIPFirewallRule_basic(t *testing.T) {
"ovh_ip_firewall_rule.rule", "source", "any"),
resource.TestCheckResourceAttr(
"ovh_ip_firewall_rule.rule", "tcp_option", "established"),
resource.TestCheckResourceAttr(
"ovh_ip_firewall_rule.rule", "destination_port", "22"),
resource.TestCheckResourceAttr(
"ovh_ip_firewall_rule.rule", "destination_port_desc", "eq 22"),
resource.TestCheckResourceAttr(
"ovh_ip_firewall_rule.rule", "source_port", "44"),
resource.TestCheckResourceAttr(
"ovh_ip_firewall_rule.rule", "source_port_desc", "eq 44"),
),
},
},
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/ip_firewall_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
subcategory : "Additional IP"
---

# ovh_ip_firewall
# ovh_ip_firewall_rule

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

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