Skip to content

Commit

Permalink
Provide informative import error message for path
Browse files Browse the repository at this point in the history
Whenever bad path is provided for import, we need to communicate
what the expected format is.

Signed-off-by: Anna Khmelnitsky <akhmelnitsky@vmware.com>
  • Loading branch information
annakhm committed Dec 31, 2024
1 parent 40ee24f commit f1fbea5
Show file tree
Hide file tree
Showing 49 changed files with 113 additions and 60 deletions.
77 changes: 65 additions & 12 deletions nsxt/policy_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
// ErrNotAPolicyPath - Define an ignorable error for policy path importer - to indicate that the given path is not a
// policy path and may be processed as an id - which is handy for legacy import method
var ErrNotAPolicyPath = errors.New("specified import identifier is not a policy path")
var ErrUnexpectedPolicyPath = errors.New("unexpected policy path")
var ErrEmptyImportID = errors.New("import identifier cannot be empty")

func isSpaceString(s string) bool {
Expand Down Expand Up @@ -410,7 +411,33 @@ func validateImportPolicyPath(policyPath string) error {
return nil
}

// This importer function accepts policy path and resource ID
func isValidResourceID(id string) bool {
if isSpaceString(id) {
return false
}
if len(id) > 1024 {
return false
}
if strings.Contains(id, "/") {
return false
}
return true
}

// This importer function accepts policy path only as import ID
func getFriendlyPolicyPathResourceImporter(pathExample string) func(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
return func(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
rd, err := nsxtPolicyPathResourceImporterHelper(d, m)
if errors.Is(err, ErrNotAPolicyPath) || errors.Is(err, ErrUnexpectedPolicyPath) {
return rd, fmt.Errorf("Invalid policy path %s; expected format: %s", d.Id(), pathExample)
} else if err != nil {
return rd, err
}
return rd, nil
}
}

// This importer function accepts policy path or resource ID
func nsxtPolicyPathResourceImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
rd, err := nsxtPolicyPathResourceImporterHelper(d, m)
if errors.Is(err, ErrNotAPolicyPath) {
Expand All @@ -421,21 +448,47 @@ func nsxtPolicyPathResourceImporter(d *schema.ResourceData, m interface{}) ([]*s
return rd, nil
}

// This importer function accepts policy path only as import ID
func nsxtPolicyPathOnlyResourceImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
return nsxtPolicyPathResourceImporterHelper(d, m)
func getMultitenancyPathExample(pathExample string) string {
return fmt.Sprintf("%s or /orgs/[org]/projects/[project]%s", pathExample, pathExample)
}

func nsxtVPCPathResourceImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
rd, err := nsxtPolicyPathResourceImporterHelper(d, m)
if err != nil {
return rd, err
// This importer function accepts policy path or resource ID
func getFriendlyPolicyPathOrIDResourceImporter(pathExample string) func(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
return func(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
rd, err := nsxtPolicyPathResourceImporterHelper(d, m)
if errors.Is(err, ErrUnexpectedPolicyPath) {
return rd, fmt.Errorf("Invalid policy path %s; expected format: %s", d.Id(), pathExample)
}
if errors.Is(err, ErrNotAPolicyPath) {
if !isValidResourceID(d.Id()) {
return rd, fmt.Errorf("Invalid policy path or id %s; expected path format: %s", d.Id(), pathExample)
}
return rd, nil
} else if err != nil {
return rd, err
}
return rd, nil
}
projectID, vpcID := getContextDataFromSchema(d)
if projectID == "" || vpcID == "" {
return rd, fmt.Errorf("imported resource policy path should have both project_id and vpc_id fields")
}

// This importer function accepts VPC path only
func getFriendlyVpcPathResourceImporter(pathExample string) func(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
return func(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
rd, err := nsxtPolicyPathResourceImporterHelper(d, m)
if errors.Is(err, ErrNotAPolicyPath) || errors.Is(err, ErrUnexpectedPolicyPath) {
return rd, fmt.Errorf("Invalid policy path %s; expected format: %s", d.Id(), pathExample)
}

if err != nil {
return rd, err
}

projectID, vpcID := getContextDataFromSchema(d)
if projectID == "" || vpcID == "" {
return rd, fmt.Errorf("imported resource policy path should have both project_id and vpc_id fields")
}
return rd, nil
}
return rd, nil
}

func nsxtPolicyPathResourceImporterHelper(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_context_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func resourceNsxtPolicyContextProfile() *schema.Resource {
Update: resourceNsxtPolicyContextProfileUpdate,
Delete: resourceNsxtPolicyContextProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/context-profiles/[profile]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_dhcp_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func resourceNsxtPolicyDhcpRelayConfig() *schema.Resource {
Update: resourceNsxtPolicyDhcpRelayConfigUpdate,
Delete: resourceNsxtPolicyDhcpRelayConfigDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/dhcp-relays/[dhcp-relay]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_dhcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func resourceNsxtPolicyDhcpServer() *schema.Resource {
Update: resourceNsxtPolicyDhcpServerUpdate,
Delete: resourceNsxtPolicyDhcpServerDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/dhcp-servers/[dhcp-server]")),
},

Schema: map[string]*schema.Schema{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func resourceNsxtPolicyDistributedFloodProtectionProfile() *schema.Resource {
Update: resourceNsxtPolicyDistributedFloodProtectionProfileUpdate,
Delete: resourceNsxtPolicyFloodProtectionProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/flood-protection-profiles/[profile]")),
},
Schema: getDistributedFloodProtectionProfile(),
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_distributed_vlan_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func resourceNsxtPolicyDistributedVlanConnection() *schema.Resource {
Update: resourceNsxtPolicyDistributedVlanConnectionUpdate,
Delete: resourceNsxtPolicyDistributedVlanConnectionDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathOnlyResourceImporter,
State: getFriendlyPolicyPathResourceImporter("/infra/distributed-vlan-connections/[connection]"),
},
Schema: metadata.GetSchemaFromExtendedSchema(distributedVlanConnectionSchema),
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_dns_forwarder_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func resourceNsxtPolicyDNSForwarderZone() *schema.Resource {
Update: resourceNsxtPolicyDNSForwarderZoneUpdate,
Delete: resourceNsxtPolicyDNSForwarderZoneDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/dns-forwarder-zones/[profile]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_gateway_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func resourceNsxtPolicyGatewayConnection() *schema.Resource {
Update: resourceNsxtPolicyGatewayConnectionUpdate,
Delete: resourceNsxtPolicyGatewayConnectionDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathOnlyResourceImporter,
State: getFriendlyPolicyPathResourceImporter("/infra/gateway-connections/[connection]"),
},
Schema: metadata.GetSchemaFromExtendedSchema(gatewayConnectionSchema),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func resourceNsxtPolicyGatewayFloodProtectionProfile() *schema.Resource {
Update: resourceNsxtPolicyGatewayFloodProtectionProfileUpdate,
Delete: resourceNsxtPolicyFloodProtectionProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/flood-protection-profiles/[profile]")),
},
Schema: getGatewayFloodProtectionProfile(),
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_global_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func resourceNsxtPolicyGlobalManager() *schema.Resource {
Update: resourceNsxtPolicyGlobalManagerUpdate,
Delete: resourceNsxtPolicyGlobalManagerDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/global-infra/global-managers/[manager]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_host_transport_node_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func resourceNsxtPolicyHostTransportNodeProfile() *schema.Resource {
Update: resourceNsxtPolicyHostTransportNodeProfileUpdate,
Delete: resourceNsxtPolicyHostTransportNodeProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/host-transport-node-profiles/[profile]"),
},
Schema: map[string]*schema.Schema{
"nsx_id": getNsxIDSchema(),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_intrusion_service_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func resourceNsxtPolicyIntrusionServiceProfile() *schema.Resource {
Update: resourceNsxtPolicyIntrusionServiceProfileUpdate,
Delete: resourceNsxtPolicyIntrusionServiceProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/settings/firewall/security/intrusion-services/profiles/[profile]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_ip_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func resourceNsxtPolicyIPBlock() *schema.Resource {
Update: resourceNsxtPolicyIPBlockUpdate,
Delete: resourceNsxtPolicyIPBlockDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/ip-blocks/[ip-block]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_ip_discovery_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func resourceNsxtPolicyIPDiscoveryProfile() *schema.Resource {
Update: resourceNsxtPolicyIPDiscoveryProfileUpdate,
Delete: resourceNsxtPolicyIPDiscoveryProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/ip-discovery-profiles/[profile]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_ip_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func resourceNsxtPolicyIPPool() *schema.Resource {
Update: resourceNsxtPolicyIPPoolUpdate,
Delete: resourceNsxtPolicyIPPoolDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/ip-pools/[ip-pool]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_lb_client_ssl_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func resourceNsxtPolicyLBClientSslProfile() *schema.Resource {
Update: resourceNsxtPolicyLBClientSslProfileUpdate,
Delete: resourceNsxtPolicyLBClientSslProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/lb-client-ssl-profiles/[profile]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_lb_http_application_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func resourceNsxtPolicyLBHttpApplicationProfile() *schema.Resource {
Update: resourceNsxtPolicyLBHttpApplicationProfileUpdate,
Delete: resourceNsxtPolicyLBHttpApplicationProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/lb-app-profiles/[profile]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_lb_http_monitor_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func resourceNsxtPolicyLBHttpMonitorProfile() *schema.Resource {
Update: resourceNsxtPolicyLBHttpMonitorProfileUpdate,
Delete: resourceNsxtPolicyLBHttpMonitorProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/lb-monitor-profiles/[profile]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_lb_https_monitor_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func resourceNsxtPolicyLBHttpsMonitorProfile() *schema.Resource {
Update: resourceNsxtPolicyLBHttpsMonitorProfileUpdate,
Delete: resourceNsxtPolicyLBHttpsMonitorProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/lb-monitor-profiles/[profile]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_lb_icmp_monitor_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func resourceNsxtPolicyLBIcmpMonitorProfile() *schema.Resource {
Update: resourceNsxtPolicyLBIcmpMonitorProfileUpdate,
Delete: resourceNsxtPolicyLBIcmpMonitorProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/lb-monitor-profiles/[profile]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_lb_passive_monitor_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func resourceNsxtPolicyLBPassiveMonitorProfile() *schema.Resource {
Update: resourceNsxtPolicyLBPassiveMonitorProfileUpdate,
Delete: resourceNsxtPolicyLBPassiveMonitorProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/lb-monitor-profiles/[profile]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_lb_tcp_monitor_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func resourceNsxtPolicyLBTcpMonitorProfile() *schema.Resource {
Update: resourceNsxtPolicyLBTcpMonitorProfileUpdate,
Delete: resourceNsxtPolicyLBTcpMonitorProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/lb-monitor-profiles/[profile]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_lb_udp_monitor_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func resourceNsxtPolicyLBUdpMonitorProfile() *schema.Resource {
Update: resourceNsxtPolicyLBUdpMonitorProfileUpdate,
Delete: resourceNsxtPolicyLBUdpMonitorProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/lb-monitor-profiles/[profile]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_mac_discovery_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func resourceNsxtPolicyMacDiscoveryProfile() *schema.Resource {
Update: resourceNsxtPolicyMacDiscoveryProfileUpdate,
Delete: resourceNsxtPolicyMacDiscoveryProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/mac-discovery-profiles/[profile]")),
},

Schema: metadata.GetSchemaFromExtendedSchema(macDiscoveryProfileSchema),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_metadata_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func resourceNsxtPolicyMetadataProxy() *schema.Resource {
Update: resourceNsxtPolicyMetadataProxyUpdate,
Delete: resourceNsxtPolicyMetadataProxyDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/metadata-proxies/[profile]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_project_ip_address_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func resourceNsxtPolicyProjectIpAddressAllocation() *schema.Resource {
Update: resourceNsxtPolicyProjectIpAddressAllocationUpdate,
Delete: resourceNsxtPolicyProjectIpAddressAllocationDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathOnlyResourceImporter,
State: getFriendlyPolicyPathResourceImporter("/orgs/[org]/projects/[project]/ip-address-allocations/[allocation]"),
},
Schema: metadata.GetSchemaFromExtendedSchema(projectIpAddressAllocationSchema),
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_qos_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func resourceNsxtPolicyQosProfile() *schema.Resource {
Update: resourceNsxtPolicyQosProfileUpdate,
Delete: resourceNsxtPolicyQosProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/qos-profiles/[profile]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func resourceNsxtPolicySegment() *schema.Resource {
Update: resourceNsxtPolicySegmentUpdate,
Delete: resourceNsxtPolicySegmentDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/segments/[segment]")),
},

Schema: getPolicyCommonSegmentSchema(false, false),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_segment_security_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func resourceNsxtPolicySegmentSecurityProfile() *schema.Resource {
Update: resourceNsxtPolicySegmentSecurityProfileUpdate,
Delete: resourceNsxtPolicySegmentSecurityProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/segment-security-profiles/[profile]")),
},

Schema: metadata.GetSchemaFromExtendedSchema(segmentSecurityProfileSchema),
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func resourceNsxtPolicyService() *schema.Resource {
Update: resourceNsxtPolicyServiceUpdate,
Delete: resourceNsxtPolicyServiceDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/services/[service]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_share.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func resourceNsxtPolicyShare() *schema.Resource {
Update: resourceNsxtPolicyShareUpdate,
Delete: resourceNsxtPolicyShareDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathOnlyResourceImporter,
State: getFriendlyPolicyPathResourceImporter("/infra/shares/[share] or /orgs/[org]/projects/[project]/infra/shares/[share]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_site.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func resourceNsxtPolicySite() *schema.Resource {
Update: resourceNsxtPolicySiteUpdate,
Delete: resourceNsxtPolicySiteDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter("/infra/sites/[site]"),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_spoof_guard_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func resourceNsxtPolicySpoofGuardProfile() *schema.Resource {
Update: resourceNsxtPolicySpoofGuardProfileUpdate,
Delete: resourceNsxtPolicySpoofGuardProfileDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/spoofguard-profiles/[profile]")),
},

Schema: map[string]*schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_policy_tier1_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func resourceNsxtPolicyTier1Gateway() *schema.Resource {
Update: resourceNsxtPolicyTier1GatewayUpdate,
Delete: resourceNsxtPolicyTier1GatewayDelete,
Importer: &schema.ResourceImporter{
State: nsxtPolicyPathResourceImporter,
State: getFriendlyPolicyPathOrIDResourceImporter(getMultitenancyPathExample("/infra/tier-1s/[gateway]")),
},

Schema: map[string]*schema.Schema{
Expand Down
Loading

0 comments on commit f1fbea5

Please sign in to comment.