Skip to content

Commit

Permalink
Merge pull request #587 from vmware/rule-id
Browse files Browse the repository at this point in the history
Fix rule_id assignment in policy resources
  • Loading branch information
annakhm authored Mar 10, 2021
2 parents 7365c6e + 293f810 commit 0d86799
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions nsxt/policy_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func setPolicyRulesInSchema(d *schema.ResourceData, rules []model.Rule) error {
setPathListInMap(elem, "scope", rule.Scope)
elem["sequence_number"] = rule.SequenceNumber
elem["nsx_id"] = rule.Id
elem["rule_id"] = rule.RuleId

var tagList []map[string]string
for _, tag := range rule.Tags {
Expand Down
1 change: 1 addition & 0 deletions nsxt/resource_nsxt_policy_gateway_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TestAccResourceNsxtPolicyGatewayPolicy_basic(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "rule.0.action", defaultAction),
resource.TestCheckResourceAttr(testResourceName, "rule.0.log_label", tag1),
resource.TestCheckResourceAttr(testResourceName, "rule.0.tag.#", "1"),
resource.TestCheckResourceAttrSet(testResourceName, "rule.0.rule_id"),
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func TestAccResourceNsxtPolicyPredefinedSecurityPolicy_rules(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "rule.0.source_groups.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "rule.0.log_label", "group2"),
resource.TestCheckResourceAttr(testResourceName, "rule.0.disabled", "true"),
resource.TestCheckResourceAttrSet(testResourceName, "rule.0.rule_id"),
resource.TestCheckResourceAttr(testResourceName, "default_rule.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "default_rule.0.action", "ALLOW"),
),
Expand Down
2 changes: 2 additions & 0 deletions nsxt/resource_nsxt_policy_security_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func TestAccResourceNsxtPolicySecurityPolicy_basic(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "rule.0.ip_version", proto1),
resource.TestCheckResourceAttr(testResourceName, "rule.0.action", defaultAction),
resource.TestCheckResourceAttr(testResourceName, "rule.0.log_label", tag1),
resource.TestCheckResourceAttrSet(testResourceName, "rule.0.rule_id"),
resource.TestCheckResourceAttr(testResourceName, "rule.0.tag.#", "1"),
),
},
Expand Down Expand Up @@ -191,6 +192,7 @@ func TestAccResourceNsxtPolicySecurityPolicy_withDependencies(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "rule.1.destinations_excluded", "false"),
resource.TestCheckResourceAttr(testResourceName, "rule.1.disabled", "false"),
resource.TestCheckResourceAttr(testResourceName, "rule.1.services.#", "0"),
resource.TestCheckResourceAttrSet(testResourceName, "rule.1.rule_id"),
),
},
{
Expand Down

0 comments on commit 0d86799

Please sign in to comment.