Skip to content

Commit

Permalink
Merge pull request #783 from ovh/dev/aamstutz/fix-dbaas-logs-input
Browse files Browse the repository at this point in the history
fix: Use Set instead of List in ovh_dbaas_logs_input.allowed_networks
  • Loading branch information
amstuta authored Dec 9, 2024
2 parents 1afa839 + cacf05f commit 4561b1d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ovh/resource_dbaas_logs_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func resourceDbaasLogsInputSchema() map[string]*schema.Schema {

// Optional
"allowed_networks": {
Type: schema.TypeList,
Type: schema.TypeSet,
Description: "IP blocks",
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Expand Down
47 changes: 47 additions & 0 deletions ovh/resource_dbaas_logs_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,47 @@ resource "ovh_dbaas_logs_input" "input" {
}
`

const testAccResourceDbaasLogsInput_noNetwork = `
data "ovh_dbaas_logs_input_engine" "logstash" {
service_name = "%s"
name = "%s"
version = "%s"
}
resource "ovh_dbaas_logs_output_graylog_stream" "stream" {
service_name = "%s"
title = "%s"
description = "%s"
}
resource "ovh_dbaas_logs_input" "input" {
service_name = ovh_dbaas_logs_output_graylog_stream.stream.service_name
description = ovh_dbaas_logs_output_graylog_stream.stream.description
title = ovh_dbaas_logs_output_graylog_stream.stream.title
engine_id = data.ovh_dbaas_logs_input_engine.logstash.id
stream_id = ovh_dbaas_logs_output_graylog_stream.stream.id
allowed_networks = []
exposed_port = "6154"
autoscale = true
min_scale_instance = 2
max_scale_instance = 4
configuration {
logstash {
input_section = <<EOF
beats {
port => 6514
ssl => true
ssl_certificate => "/etc/ssl/private/server.crt"
ssl_key => "/etc/ssl/private/server.key"
}
EOF
}
}
}
`

func init() {
resource.AddTestSweepers("ovh_dbaas_logs_input", &resource.Sweeper{
Name: "ovh_dbaas_logs_input",
Expand Down Expand Up @@ -207,6 +248,8 @@ func TestAccResourceDbaasLogsInput_basic(t *testing.T) {
serviceName, name, version, serviceName, title, desc, 4)
configUpdated := fmt.Sprintf(testAccResourceDbaasLogsInput_updated,
serviceName, name, version, serviceName, title, desc)
configNoNetwork := fmt.Sprintf(testAccResourceDbaasLogsInput_noNetwork,
serviceName, name, version, serviceName, title, desc)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckDbaasLogsInput(t) },
Expand Down Expand Up @@ -313,6 +356,10 @@ func TestAccResourceDbaasLogsInput_basic(t *testing.T) {
),
),
},
{
Config: configNoNetwork,
Check: resource.TestCheckResourceAttr("ovh_dbaas_logs_input.input", "allowed_networks.#", "0"),
},
},
})
}
2 changes: 1 addition & 1 deletion ovh/types_dbaas_logs_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (opts *DbaasLogsInputOpts) FromResource(d *schema.ResourceData) *DbaasLogsI
opts.StreamId = d.Get("stream_id").(string)
opts.Title = d.Get("title").(string)

networks := d.Get("allowed_networks").([]interface{})
networks := d.Get("allowed_networks").(*schema.Set).List()
if len(networks) > 0 {
networksString := make([]string, len(networks))
for i, net := range networks {
Expand Down

0 comments on commit 4561b1d

Please sign in to comment.