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 Set instead of List in ovh_dbaas_logs_input.allowed_networks #783

Merged
merged 1 commit into from
Dec 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/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