Skip to content

Commit

Permalink
update code per review
Browse files Browse the repository at this point in the history
  • Loading branch information
magodo committed Apr 27, 2020
1 parent ea247dc commit 70ba52e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Expand Up @@ -17,7 +17,7 @@ func SentinelAlertRuleID(input string) (*SentinelAlertRuleId, error) {
// Example ID: /subscriptions/<sub1>/resourceGroups/<grp1>/providers/Microsoft.OperationalInsights/workspaces/<workspace1>/providers/Microsoft.SecurityInsights/alertRules/<rule1>
groups := regexp.MustCompile(`^(.+)/providers/Microsoft\.SecurityInsights/alertRules/(.+)$`).FindStringSubmatch(input)
if len(groups) != 3 {
return nil, fmt.Errorf("faield to parse Sentinel Alert Rule ID: %q", input)
return nil, fmt.Errorf("failed to parse Sentinel Alert Rule ID: %q", input)
}

workspace, name := groups[1], groups[2]
Expand Down
Expand Up @@ -100,7 +100,11 @@ func resourceArmSentinelAlertRuleMsSecurityIncident() *schema.Resource {
"text_whitelist": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringIsNotEmpty,
},
},
},
}
Expand Down Expand Up @@ -142,9 +146,8 @@ func resourceArmSentinelAlertRuleMsSecurityIncidentCreateUpdate(d *schema.Resour
},
}

// If `text_whitelist` is set, it has to at least contain one item.
if whitelist := d.Get("text_whitelist").(*schema.Set).List(); len(whitelist) != 0 {
param.DisplayNamesFilter = utils.ExpandStringSlice(whitelist)
if whitelist, ok := d.GetOk("text_whitelist"); ok {
param.DisplayNamesFilter = utils.ExpandStringSlice(whitelist.(*schema.Set).List())
}

// Service avoid concurrent update of this resource via checking the "etag" to guarantee it is the same value as last Read.
Expand Down

0 comments on commit 70ba52e

Please sign in to comment.