Skip to content

Commit

Permalink
remove data source
Browse files Browse the repository at this point in the history
Signed-off-by: graysonwu <[email protected]>
  • Loading branch information
GraysonWu committed Dec 14, 2023
1 parent abfa16b commit 451bab7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 101 deletions.
86 changes: 0 additions & 86 deletions nsxt/data_source_nsxt_policy_security_policy_rule.go

This file was deleted.

2 changes: 1 addition & 1 deletion nsxt/policy_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func getSecurityPolicyAndGatewayRuleSchema(scopeRequired bool, isIds bool, nsxID
Description: "Sequence number of the this rule",
Required: true,
}
ruleSchema["context"] = getContextSchema()
ruleSchema["context"] = getComputedContextSchema()
} else {
ruleSchema["sequence_number"] = &schema.Schema{
Type: schema.TypeInt,
Expand Down
1 change: 0 additions & 1 deletion nsxt/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ func Provider() *schema.Provider {
"nsxt_manager_cluster_node": dataSourceNsxtManagerClusterNode(),
"nsxt_policy_host_transport_node_profile": dataSourceNsxtPolicyHostTransportNodeProfile(),
"nsxt_transport_node": dataSourceNsxtEdgeTransportNode(),
"nsxt_policy_security_policy_rule": dataSourceNsxtPolicySecurityPolicyRule(),
},

ResourcesMap: map[string]*schema.Resource{
Expand Down
14 changes: 1 addition & 13 deletions nsxt/resource_nsxt_policy_security_policy_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,8 @@ resource "nsxt_policy_parent_security_policy" "policy1" {
}

func testAccNsxtPolicySecurityPolicyRuleTemplate(withContext bool, name, action, direction, ipVersion, seqNum string) string {
context := ""
if withContext {
context = testAccNsxtPolicyMultitenancyContext()
}
return testAccNsxtPolicySecurityPolicyRuleDeps(withContext) + fmt.Sprintf(`
resource "nsxt_policy_security_policy_rule" "test" {
%s
display_name = "%s"
policy_path = nsxt_policy_parent_security_policy.policy1.path
action = "%s"
Expand All @@ -218,12 +213,5 @@ resource "nsxt_policy_security_policy_rule" "test" {
}
depends_on = [nsxt_policy_parent_security_policy.policy1, nsxt_policy_group.group2]
}
data "nsxt_policy_security_policy_rule" "test" {
%s
display_name = "%s"
policy_path = nsxt_policy_parent_security_policy.policy1.path
depends_on = [nsxt_policy_security_policy_rule.test]
}`, context, name, action, direction, ipVersion, seqNum, context, name)
}`, name, action, direction, ipVersion, seqNum)
}
21 changes: 21 additions & 0 deletions nsxt/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,27 @@ func getContextSchema() *schema.Schema {
}
}

func getComputedContextSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Description: "Resource context",
Optional: true,
Computed: true,
MaxItems: 1,
ForceNew: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"project_id": {
Type: schema.TypeString,
Description: "Id of the project which the resource belongs to.",
Required: true,
ForceNew: true,
},
},
},
}
}

func getCustomizedMPTagsFromSchema(d *schema.ResourceData, schemaName string) []mp_model.Tag {
tags := d.Get(schemaName).(*schema.Set).List()
tagList := make([]mp_model.Tag, 0)
Expand Down

0 comments on commit 451bab7

Please sign in to comment.