From 53db2388abee5f9857dd2514cf1189990750ba57 Mon Sep 17 00:00:00 2001 From: asarfaty Date: Mon, 23 Nov 2020 11:56:28 +0200 Subject: [PATCH 1/2] Skip marked_for_delete data sources in searh by name/type --- nsxt/policy_gm_search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nsxt/policy_gm_search.go b/nsxt/policy_gm_search.go index 8fbccc3a3..ad2a600a7 100644 --- a/nsxt/policy_gm_search.go +++ b/nsxt/policy_gm_search.go @@ -101,7 +101,7 @@ func policyDataSourceResourceReadWithValidation(d *schema.ResourceData, connecto } func listPolicyResourcesByType(connector *client.RestConnector, resourceType *string, additionalQuery *string) ([]*data.StructValue, error) { - query := fmt.Sprintf("resource_type:%s", *resourceType) + query := fmt.Sprintf("resource_type:%s AND marked_for_delete:false", *resourceType) return searchPolicyResources(connector, *buildPolicyResourcesQuery(&query, additionalQuery)) } From 589e05b4bc2b7a96bf5e25af27b43308031356dc Mon Sep 17 00:00:00 2001 From: asarfaty Date: Thu, 26 Nov 2020 12:13:24 +0200 Subject: [PATCH 2/2] Add the same for search by id --- nsxt/policy_gm_search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nsxt/policy_gm_search.go b/nsxt/policy_gm_search.go index ad2a600a7..ab0801419 100644 --- a/nsxt/policy_gm_search.go +++ b/nsxt/policy_gm_search.go @@ -106,7 +106,7 @@ func listPolicyResourcesByType(connector *client.RestConnector, resourceType *st } func listPolicyResourcesByID(connector *client.RestConnector, resourceID *string, additionalQuery *string) ([]*data.StructValue, error) { - query := fmt.Sprintf("id:%s", *resourceID) + query := fmt.Sprintf("id:%s AND marked_for_delete:false", *resourceID) return searchPolicyResources(connector, *buildPolicyResourcesQuery(&query, additionalQuery)) }