Skip to content
Open
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
4 changes: 3 additions & 1 deletion docs/data-sources/eg_connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ The `kafka_detail` block supports:

* `user_name` - The username of the Kafka instance.

* `acks` - The number of confirmation signals the producer‌ needs to receive to consider the message sent successfully.
* `acks` - The number of confirmation signals the producer needs to receive to consider the message sent successfully.

* `address` - The connection address of Kafka instance.

<a name="data_connections_flavor"></a>
The `flavor` block supports:
Expand Down
4 changes: 4 additions & 0 deletions docs/data-sources/eg_custom_event_channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ The following arguments are supported:

* `name` - (Optional, String) Specifies the channel name used to query specified custom event channel.

* `fuzzy_name` - (Optional, String) Specifies the name of the channels to be queried for fuzzy matching.

* `sort` - (Optional, String) Specifies the sorting method for query results.

* `enterprise_project_id` - (Optional, String) Specifies the ID of the enterprise project to which the custom event
channels belong.

Expand Down
20 changes: 19 additions & 1 deletion docs/data-sources/eg_custom_event_sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ The following arguments are supported:

* `name` - (Optional, String) Specifies the event source name used to query specified custom event source.

* `fuzzy_name` - (Optional, String) Specifies the name of the channels to be queried for fuzzy matching.

* `sort` - (Optional, String) Specifies the sorting method for query results.

## Attribute Reference

In addition to all arguments above, the following attributes are exported:

* `id` - The data source ID.

* `sources` - The filtered custom event source.
The [object](#eg_custom_event_sources) structure is documented below.
The [sources](#eg_custom_event_sources) structure is documented below.

<a name="eg_custom_event_sources"></a>
The `sources` block supports:
Expand All @@ -62,6 +66,20 @@ The `sources` block supports:
+ **RUNNING**
+ **ERROR**

* `detail` - The message instance link information, in JSON format.

* `error_info` - The error information of the custom event source.
The [error_info](#data_custom_event_sources_error_info) structure is documented below.

* `created_at` - The creation time of the custom event source.

* `updated_at` - The update time of the custom event source.

<a name="data_custom_event_sources_error_info"></a>
The `error_info` block supports:

* `error_code` - The error code of current source.

* `error_detail` - The error detail of current source.

* `error_msg` - The error message of current source.
20 changes: 20 additions & 0 deletions docs/resources/eg_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ The `KafkaDetail` block supports:

Changing this parameter will create a new resource.

* `security_protocol` - (Optional, String, ForceNew) Specifies the security protocol of the kafka instance.

Changing this parameter will create a new resource.

## Attribute Reference

In addition to all arguments above, the following attributes are exported:
Expand All @@ -128,10 +132,26 @@ In addition to all arguments above, the following attributes are exported:

* `status` - Indicates the status of the connection.

* `agency` - Indicates the user-delegated name used for private network target connection.

* `created_at` - The creation time of the connection.

* `updated_at` - The last update time of the connection.

* `flavor` - The configuration details of the kafka instance.
The [flavor](#connection_flavor) structure is documented below.

<a name="connection_flavor"></a>
The `flavor` block supports:

* `name` - The name of the kafka instance.

* `bandwidth_type` - The bandwidth type of the kafka instance.

* `concurrency` - The concurrency number of the kafka instance.

* `concurrency_type` - The concurrency type of the kafka instance.

## Import

The connection can be imported using the `id`, e.g.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ output "is_kafka_detail_and_valid" {
lookup(local.kafka_connection_filter_result, "enable_sasl_ssl", "") == true,
lookup(local.kafka_connection_filter_result, "user_name", "") != "",
lookup(local.kafka_connection_filter_result, "acks", "") != "",
lookup(local.kafka_connection_filter_result, "address", "") != "",
])
}
`, acceptance.HW_EG_CONNECTION_IDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,107 @@ output "eps_id_not_found_validation_pass" {
}
`, testAccDataCustomEventChannels_base_withEpsId(), acceptance.HW_ENTERPRISE_PROJECT_ID_TEST, randUUID)
}

func TestAccDataCustomEventChannels_fuzzyName(t *testing.T) {
var (
baseRes = "huaweicloud_eg_custom_event_channel.test"
byFuzzy = "data.huaweicloud_eg_custom_event_channels.filter_by_fuzzy_name"

obj interface{}
rc = acceptance.InitResourceCheck(baseRes, &obj, getCustomEventChannelFunc)
dcFuzzy = acceptance.InitDataSourceCheck(byFuzzy)
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.TestAccPreCheck(t) },
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: rc.CheckResourceDestroy(),
Steps: []resource.TestStep{
{
Config: testAccDataCustomEventChannels_fuzzyName(),
Check: resource.ComposeTestCheckFunc(
rc.CheckResourceExists(),
dcFuzzy.CheckResourceExists(),
resource.TestCheckOutput("is_fuzzy_name_filter_useful", "true"),
),
},
},
})
}

func testAccDataCustomEventChannels_fuzzyName() string {
name := acceptance.RandomAccResourceName()
fuzzyName := name[:len(name)-3]

return fmt.Sprintf(`
resource "huaweicloud_eg_custom_event_channel" "test" {
name = "%[1]s"
}

data "huaweicloud_eg_custom_event_channels" "filter_by_fuzzy_name" {
depends_on = [
huaweicloud_eg_custom_event_channel.test,
]

fuzzy_name = "%[2]s"
}

locals {
filter_result = [for v in data.huaweicloud_eg_custom_event_channels.filter_by_fuzzy_name.channels[*].name :
can(regex(".*%[2]s.*", v))]
}

output "is_fuzzy_name_filter_useful" {
value = alltrue(local.filter_result) && length(local.filter_result) > 0
}
`, name, fuzzyName)
}

func TestAccDataCustomEventChannels_sort(t *testing.T) {
var (
baseRes = "huaweicloud_eg_custom_event_channel.test"
bySort = "data.huaweicloud_eg_custom_event_channels.sort_by_name"

obj interface{}
rc = acceptance.InitResourceCheck(baseRes, &obj, getCustomEventChannelFunc)
dcSort = acceptance.InitDataSourceCheck(bySort)
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.TestAccPreCheck(t) },
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: rc.CheckResourceDestroy(),
Steps: []resource.TestStep{
{
Config: testAccDataCustomEventChannels_sort(),
Check: resource.ComposeTestCheckFunc(
rc.CheckResourceExists(),
dcSort.CheckResourceExists(),
resource.TestCheckOutput("is_sort_useful", "true"),
),
},
},
})
}

func testAccDataCustomEventChannels_sort() string {
name := acceptance.RandomAccResourceName()

return fmt.Sprintf(`
resource "huaweicloud_eg_custom_event_channel" "test" {
name = "%[1]s"
}

data "huaweicloud_eg_custom_event_channels" "sort_by_name" {
depends_on = [
huaweicloud_eg_custom_event_channel.test,
]

sort = "created_time:DESC"
}

output "is_sort_useful" {
value = length(data.huaweicloud_eg_custom_event_channels.sort_by_name.channels) > 0
}
`, name)
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,129 @@ output "channel_id_not_found_validation_pass" {
}
`, testAccDataCustomEventSources_base(), acceptance.HW_EG_CHANNEL_ID, randUUID)
}

func TestAccDataCustomEventSources_filterByFuzzyName(t *testing.T) {
var (
baseRes = "huaweicloud_eg_custom_event_source.test"
byFuzzyName = "data.huaweicloud_eg_custom_event_sources.filter_by_fuzzy_name"
fuzzyNameNotFound = "data.huaweicloud_eg_custom_event_sources.fuzzy_name_not_found"

obj custom.Source
rc = acceptance.InitResourceCheck(baseRes, &obj, getCustomEventSourceFunc)
dcByFuzzyName = acceptance.InitDataSourceCheck(byFuzzyName)
dcFuzzyNameNotFound = acceptance.InitDataSourceCheck(fuzzyNameNotFound)
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acceptance.TestAccPreCheck(t)
acceptance.TestAccPreCheckEgChannelId(t)
},
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: rc.CheckResourceDestroy(),
Steps: []resource.TestStep{
{
Config: testAccDataCustomEventSources_filterByFuzzyName(),
Check: resource.ComposeTestCheckFunc(
rc.CheckResourceExists(),
dcByFuzzyName.CheckResourceExists(),
resource.TestCheckOutput("is_fuzzy_name_filter_useful", "true"),
dcFuzzyNameNotFound.CheckResourceExists(),
resource.TestCheckOutput("fuzzy_name_not_found_validation_pass", "true"),
),
},
},
})
}

func testAccDataCustomEventSources_filterByFuzzyName() string {
randUUID, _ := uuid.GenerateUUID()

return fmt.Sprintf(`
%[1]s

data "huaweicloud_eg_custom_event_sources" "filter_by_fuzzy_name" {
depends_on = [
huaweicloud_eg_custom_event_source.test,
]

fuzzy_name = huaweicloud_eg_custom_event_source.test.name
}

data "huaweicloud_eg_custom_event_sources" "fuzzy_name_not_found" {
// Since a random name is used, there is no dependency relationship with resource attachment, and the dependency needs
// to be manually set.
depends_on = [
huaweicloud_eg_custom_event_source.test,
]

fuzzy_name = "%[2]s"
}

locals {
filter_result = [for v in data.huaweicloud_eg_custom_event_sources.filter_by_fuzzy_name.sources[*].name :
length(regexall("${huaweicloud_eg_custom_event_source.test.name}", v)) > 0]
}

output "is_fuzzy_name_filter_useful" {
value = alltrue(local.filter_result) && length(local.filter_result) > 0
}

output "fuzzy_name_not_found_validation_pass" {
value = length(data.huaweicloud_eg_custom_event_sources.fuzzy_name_not_found.sources) == 0
}
`, testAccDataCustomEventSources_base(), randUUID)
}

func TestAccDataCustomEventSources_filterBySort(t *testing.T) {
var (
baseRes = "huaweicloud_eg_custom_event_source.test"
bySort = "data.huaweicloud_eg_custom_event_sources.filter_by_sort"

obj custom.Source
rc = acceptance.InitResourceCheck(baseRes, &obj, getCustomEventSourceFunc)
dcBySort = acceptance.InitDataSourceCheck(bySort)
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acceptance.TestAccPreCheck(t)
acceptance.TestAccPreCheckEgChannelId(t)
},
ProviderFactories: acceptance.TestAccProviderFactories,
CheckDestroy: rc.CheckResourceDestroy(),
Steps: []resource.TestStep{
{
Config: testAccDataCustomEventSources_filterBySort(),
Check: resource.ComposeTestCheckFunc(
rc.CheckResourceExists(),
dcBySort.CheckResourceExists(),
resource.TestCheckResourceAttr(bySort, "sources.#", "1"),
),
},
},
})
}

func testAccDataCustomEventSources_filterBySort() string {
name := acceptance.RandomAccResourceName()

return fmt.Sprintf(`
resource "huaweicloud_eg_custom_event_source" "test" {
channel_id = "%[1]s"
name = "%[2]s"
}

data "huaweicloud_eg_custom_event_sources" "filter_by_sort" {
depends_on = [
huaweicloud_eg_custom_event_source.test,
]

sort = "created_time:asc"
}

output "is_sort_filter_useful" {
value = length(data.huaweicloud_eg_custom_event_sources.filter_by_sort.sources) > 0
}
`, acceptance.HW_EG_CHANNEL_ID, name)
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestAccConnection_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(rName, "status"),
resource.TestCheckResourceAttrSet(rName, "created_at"),
resource.TestCheckResourceAttrSet(rName, "updated_at"),
resource.TestCheckResourceAttrSet(rName, "agency"),
),
},
{
Expand Down Expand Up @@ -157,6 +158,11 @@ func TestAccConnection_kafka(t *testing.T) {
"huaweicloud_dms_kafka_instance.test", "connect_address"),
resource.TestCheckResourceAttrSet(rName, "status"),
resource.TestCheckResourceAttrSet(rName, "created_at"),
resource.TestCheckResourceAttrSet(rName, "flavor"),
resource.TestCheckResourceAttrSet(rName, "flavor.0.bandwidth_type"),
resource.TestCheckResourceAttrSet(rName, "flavor.0.concurrency"),
resource.TestCheckResourceAttrSet(rName, "flavor.0.concurrency_type"),
resource.TestCheckResourceAttrSet(rName, "flavor.0.name"),
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ func DataSourceConnections() *schema.Resource {
Description: `The number of confirmation signals the producer
needs to receive to consider the message sent successfully.`,
},
"address": {
Type: schema.TypeString,
Computed: true,
Description: `The connection address of Kafka instance.`,
},
},
},
Description: `The Kafka detail information for the connection.`,
Expand Down Expand Up @@ -300,6 +305,7 @@ func flattenConnectionKafkaDetail(kafkaDetail interface{}) []interface{} {
"enable_sasl_ssl": utils.PathSearch("enable_sasl_ssl", kafkaDetail, nil),
"user_name": utils.PathSearch("user_name", kafkaDetail, nil),
"acks": utils.PathSearch("acks", kafkaDetail, nil),
"address": utils.PathSearch("addr", kafkaDetail, nil),
},
}
}
Expand Down
Loading
Loading