Skip to content

Commit

Permalink
Fix test and docs for external id in policy group
Browse files Browse the repository at this point in the history
  • Loading branch information
annakhm committed May 9, 2022
1 parent c79be70 commit c99582d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions nsxt/resource_nsxt_policy_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func getExternalIDExpressionSchema() *schema.Resource {
"external_ids": {
Type: schema.TypeSet,
Required: true,
Description: "List of external ids",
Description: "List of external IDs",
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand All @@ -140,6 +140,7 @@ func getExternalIDExpressionSchema() *schema.Resource {
Optional: true,
Description: "External ID member type, default to virtual machine if not specified",
ValidateFunc: validation.StringInSlice(externalMemberTypeValues, false),
Default: model.ExternalIDExpression_MEMBER_TYPE_VIRTUALMACHINE,
},
},
}
Expand Down Expand Up @@ -460,9 +461,6 @@ func buildGroupMacAddressData(ipaddr interface{}) (*data.StructValue, error) {
func buildGroupExternalIDExpressionData(externalID interface{}) (*data.StructValue, error) {
idMap := externalID.(map[string]interface{})
memberType := idMap["member_type"].(string)
if memberType == "" {
memberType = model.ExternalIDExpression_MEMBER_TYPE_VIRTUALMACHINE
}
var extIDs []string

for _, extID := range idMap["external_ids"].(*schema.Set).List() {
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestAccResourceNsxtGlobalPolicyGroup_externalIDCriteria(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "domain", defaultDomain),
resource.TestCheckResourceAttrSet(testResourceName, "path"),
resource.TestCheckResourceAttrSet(testResourceName, "revision"),
resource.TestCheckNoResourceAttr(testResourceName, "conjunction"),
resource.TestCheckResourceAttr(testResourceName, "conjunction.#", "0"),
resource.TestCheckResourceAttr(testResourceName, "tag.#", "2"),
resource.TestCheckResourceAttr(testResourceName, "criteria.#", "1"),
),
Expand Down
6 changes: 3 additions & 3 deletions website/docs/r/policy_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ resource "nsxt_policy_group" "group1" {
criteria {
external_id_expression {
member_type = "VirtualMachine"
member_type = "VirtualMachine"
external_ids = ["520ba7b0-d9f8-87b1-6f44-15bbeb7935c7", "52748a9e-d61d-e29b-d54b-07f169ff0ee8-4000"]
}
}
Expand Down Expand Up @@ -170,8 +170,8 @@ The following arguments are supported:
* `path_expression` - (Optional) An expression block to specify direct group members by policy path.
* `member_paths` - (Required) List of policy paths for direct members for this Group (such as Segments, Segment ports, Groups etc).
* `external_id_expression` - (Optional) An expression block to specify external IDs for the specified member type for this Group.
* `member_type` - (Required) External ID member type. Must be one of: `VirtualMachine`, `VirtualNetworkInterface`, `CloudNativeServiceInstance`, or `PhysicalServer`.
* `external_ids ` - (Required) List of external IDs for the specified member type.
* `member_type` - (Optional) External ID member type. Must be one of: `VirtualMachine`, `VirtualNetworkInterface`, `CloudNativeServiceInstance`, or `PhysicalServer`. Defaults to `VirtualMachine`.
* `external_ids` - (Required) List of external IDs for the specified member type.
* `condition` (Optional) A repeatable condition block to select this Group's members. When multiple `condition` blocks are used in a single `criteria` they form a nested expression that's implicitly ANDed together and each nested condition must used the same `member_type`.
* `key` (Required) Specifies the attribute to query. Must be one of: `Tag`, `ComputerName`, `OSName` or `Name`. For a `member_type` other than `VirtualMachine`, only the `Tag` key is supported.
* `member_type` (Required) Specifies the type of resource to query. Must be one of: `IPSet`, `LogicalPort`, `LogicalSwitch`, `Segment`, `SegmentPort` or `VirtualMachine`.
Expand Down

0 comments on commit c99582d

Please sign in to comment.