Skip to content

Commit

Permalink
PLT-1465 : Fixed DNS Filter error (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM authored Nov 4, 2024
1 parent d706018 commit 6ca4f10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ data "spectrocloud_private_cloud_gateway" "gateway" {
}

data "spectrocloud_privatecloudgateway_dns_map" "gateway_dns_map" {
search_domain_name = "spectrocloud.dev"
search_domain_name = "spectrocloud.com"
# Option to filter with network, if more than one dns map in same search_domain_name.
# network = "VM-NETWORK"
network = "VM-NETWORK2"
private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.gateway.id
}

Expand Down
10 changes: 8 additions & 2 deletions spectrocloud/data_source_pcg_dns_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,17 @@ func dataSourceDNSMapRead(_ context.Context, d *schema.ResourceData, m interface
matchDNSMap := &models.V1VsphereDNSMappings{}
for _, dnsMap := range DNSMappings.Items {
if name == *dnsMap.Spec.DNSName {
matchDNSMap.Items = append(matchDNSMap.Items, dnsMap)
if network != "" {
if network == *dnsMap.Spec.Network {
matchDNSMap.Items = append(matchDNSMap.Items, dnsMap)
}
} else {
matchDNSMap.Items = append(matchDNSMap.Items, dnsMap)
}
}
}
if len(matchDNSMap.Items) == 0 {
err := fmt.Errorf("error: No DNS Map identified for name `%s`. Kindly re-try with up valid `name`", name)
err := fmt.Errorf("error: No DNS Map identified for name `%s` and network `%s`. Kindly re-try with up valid `name` and `network`", name, network)
return diag.FromErr(err)
} else if len(matchDNSMap.Items) == 1 {
err := setBackDNSMap(matchDNSMap.Items[0], d)
Expand Down

0 comments on commit 6ca4f10

Please sign in to comment.