-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package azure | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/Azure/azure-sdk-for-go/profiles/latest/privatedns/mgmt/privatedns" | ||
) | ||
|
||
// PrivateDNSZoneExistsE indicates whether the specified private DNS zone exists. | ||
func PrivateDNSZoneExistsE(zoneName string, resourceGroupName string, subscriptionID string) (bool, error) { | ||
_, err := GetPrivateDNSZoneE(zoneName, resourceGroupName, subscriptionID) | ||
if err != nil { | ||
if ResourceNotFoundErrorExists(err) { | ||
return false, nil | ||
} | ||
return false, err | ||
} | ||
return true, nil | ||
} | ||
|
||
// GetPrivateDNSZoneE gets the private DNS zone object | ||
func GetPrivateDNSZoneE(zoneName string, resGroupName string, subscriptionID string) (*privatedns.PrivateZone, error) { | ||
rgName, err := getTargetAzureResourceGroupName(resGroupName) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client, err := CreatePrivateDnsZonesClientE(subscriptionID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
zone, err := client.Get(context.Background(), rgName, zoneName) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &zone, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package azure | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
/* | ||
The below tests are currently stubbed out, with the expectation that they will throw errors. | ||
If/when CRUD methods are introduced for Azure Synapse, these tests can be extended | ||
*/ | ||
func TestPrivateDNSZoneExists(t *testing.T) { | ||
t.Parallel() | ||
|
||
zoneName := "" | ||
resourceGroupName := "" | ||
subscriptionID := "" | ||
|
||
exists, err := PrivateDNSZoneExistsE(zoneName, resourceGroupName, subscriptionID) | ||
|
||
require.False(t, exists) | ||
require.Error(t, err) | ||
} | ||
|
||
func TestPrivateDNSZoneExistsE(t *testing.T) { | ||
t.Parallel() | ||
|
||
resGroupName := "" | ||
subscriptionID := "" | ||
zoneName := "" | ||
|
||
_, err := GetPrivateDNSZoneE(subscriptionID, resGroupName, zoneName) | ||
require.Error(t, err) | ||
} |