Skip to content

Commit

Permalink
feat(secmaster/indicator): add id in type struct (#4550)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason-Zhang9309 authored Apr 7, 2024
1 parent e0c09f1 commit 2615802
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docs/resources/secmaster_indicator.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Manages a SecMaster indicator resource within HuaweiCloud.

```hcl
variable "workspace_id" {}
variable "type_id" {}
resource "huaweicloud_secmaster_indicator" "test" {
workspace_id = var.workspace_id
Expand All @@ -20,6 +21,7 @@ resource "huaweicloud_secmaster_indicator" "test" {
type {
category = "Domain"
indicator_type = "Domain"
id = var.type_id
}
data_source {
Expand Down Expand Up @@ -94,6 +96,8 @@ The `type` block supports:

* `indicator_type` - (Required, String) Specifies the indicator type.

* `id` - (Required, String) Specifies the indicator type ID.

<a name="Indicator_DataSource"></a>
The `data_source` block supports:

Expand Down
9 changes: 7 additions & 2 deletions huaweicloud/services/acceptance/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ var (

// The SecMaster workspace ID
HW_SECMASTER_WORKSPACE_ID = os.Getenv("HW_SECMASTER_WORKSPACE_ID")
// The SecMaster indicator ID
HW_SECMASTER_INDICATOR_TYPE_ID = os.Getenv("HW_SECMASTER_INDICATOR_TYPE_ID")
HW_SECMASTER_INDICATOR_TYPE_ID_UPDATE = os.Getenv("HW_SECMASTER_INDICATOR_TYPE_ID_UPDATE")

// The SecMaster workspace ID
HW_SECMASTER_PIPELINE_ID = os.Getenv("HW_SECMASTER_PIPELINE_ID")
Expand Down Expand Up @@ -1095,8 +1098,10 @@ func TestAccPreCheckSourceImage(t *testing.T) {

// lintignore:AT003
func TestAccPreCheckSecMaster(t *testing.T) {
if HW_SECMASTER_WORKSPACE_ID == "" {
t.Skip("HW_SECMASTER_WORKSPACE_ID must be set for SecMaster acceptance tests")
if HW_SECMASTER_WORKSPACE_ID == "" || HW_SECMASTER_INDICATOR_TYPE_ID == "" ||
HW_SECMASTER_INDICATOR_TYPE_ID_UPDATE == "" {
t.Skip("HW_SECMASTER_WORKSPACE_ID, HW_SECMASTER_INDICATOR_TYPE_ID and HW_SECMASTER_INDICATOR_TYPE_ID_UPDATE" +
" must be set for SecMaster acceptance tests")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ resource "huaweicloud_secmaster_indicator" "test" {
type {
category = "Domain"
indicator_type = "Domain"
id = "%s"
}
data_source {
Expand All @@ -143,7 +144,7 @@ resource "huaweicloud_secmaster_indicator" "test" {
granularity = "1"
value = "test.terraform.com"
}
`, acceptance.HW_SECMASTER_WORKSPACE_ID, name)
`, acceptance.HW_SECMASTER_WORKSPACE_ID, name, acceptance.HW_SECMASTER_INDICATOR_TYPE_ID)
}

func testIndicator_basic_update(name string) string {
Expand All @@ -155,6 +156,7 @@ resource "huaweicloud_secmaster_indicator" "test" {
type {
category = "URL"
indicator_type = "URL"
id = "%s"
}
data_source {
Expand All @@ -171,7 +173,7 @@ resource "huaweicloud_secmaster_indicator" "test" {
granularity = "1"
value = "/v1/test"
}
`, acceptance.HW_SECMASTER_WORKSPACE_ID, name)
`, acceptance.HW_SECMASTER_WORKSPACE_ID, name, acceptance.HW_SECMASTER_INDICATOR_TYPE_ID_UPDATE)
}

func testIndicatorImportState(name string) resource.ImportStateIdFunc {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ func indicatorIndicatorTypeSchema() *schema.Resource {
Required: true,
Description: `Specifies the indicator type.`,
},
"id": {
Type: schema.TypeString,
Required: true,
Description: `Specifies the indicator type ID.`,
},
},
}
return &sc
Expand Down Expand Up @@ -278,6 +283,7 @@ func buildIndicatorTypeOpts(rawParams interface{}) map[string]interface{} {
params := map[string]interface{}{
"category": utils.ValueIngoreEmpty(raw["category"]),
"indicator_type": utils.ValueIngoreEmpty(raw["indicator_type"]),
"id": utils.ValueIngoreEmpty(raw["id"]),
}
return params
}
Expand Down Expand Up @@ -404,6 +410,7 @@ func flattenGetIndicatorResponseBodyIndicatorType(resp interface{}) []interface{
map[string]interface{}{
"category": utils.PathSearch("category", curJson, nil),
"indicator_type": utils.PathSearch("indicator_type", curJson, nil),
"id": utils.PathSearch("id", curJson, nil),
},
}
return rst
Expand Down

0 comments on commit 2615802

Please sign in to comment.