Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ManagedHSM endpoint and resource id #689

Merged
merged 1 commit into from Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions autorest/azure/environments.go
Expand Up @@ -51,6 +51,7 @@ type ResourceIdentifier struct {
ServiceBus string `json:"serviceBus"`
SQLDatabase string `json:"sqlDatabase"`
CosmosDB string `json:"cosmosDB"`
ManagedHSM string `json:"managedHSM"`
}

// Environment represents a set of endpoints for each of Azure's Clouds.
Expand All @@ -63,6 +64,7 @@ type Environment struct {
ActiveDirectoryEndpoint string `json:"activeDirectoryEndpoint"`
GalleryEndpoint string `json:"galleryEndpoint"`
KeyVaultEndpoint string `json:"keyVaultEndpoint"`
ManagedHSMEndpoint string `json:"managedHSMEndpoint"`
GraphEndpoint string `json:"graphEndpoint"`
ServiceBusEndpoint string `json:"serviceBusEndpoint"`
BatchManagementEndpoint string `json:"batchManagementEndpoint"`
Expand All @@ -74,6 +76,7 @@ type Environment struct {
SQLDatabaseDNSSuffix string `json:"sqlDatabaseDNSSuffix"`
TrafficManagerDNSSuffix string `json:"trafficManagerDNSSuffix"`
KeyVaultDNSSuffix string `json:"keyVaultDNSSuffix"`
ManagedHSMDNSSuffix string `json:"managedHSMDNSSuffix"`
ServiceBusEndpointSuffix string `json:"serviceBusEndpointSuffix"`
ServiceManagementVMDNSSuffix string `json:"serviceManagementVMDNSSuffix"`
ResourceManagerVMDNSSuffix string `json:"resourceManagerVMDNSSuffix"`
Expand All @@ -95,6 +98,7 @@ var (
ActiveDirectoryEndpoint: "https://login.microsoftonline.com/",
GalleryEndpoint: "https://gallery.azure.com/",
KeyVaultEndpoint: "https://vault.azure.net/",
ManagedHSMEndpoint: "https://managedhsm.azure.net/",
GraphEndpoint: "https://graph.windows.net/",
ServiceBusEndpoint: "https://servicebus.windows.net/",
BatchManagementEndpoint: "https://batch.core.windows.net/",
Expand All @@ -106,6 +110,7 @@ var (
SQLDatabaseDNSSuffix: "database.windows.net",
TrafficManagerDNSSuffix: "trafficmanager.net",
KeyVaultDNSSuffix: "vault.azure.net",
ManagedHSMDNSSuffix: "managedhsm.azure.net",
ServiceBusEndpointSuffix: "servicebus.windows.net",
ServiceManagementVMDNSSuffix: "cloudapp.net",
ResourceManagerVMDNSSuffix: "cloudapp.azure.com",
Expand All @@ -125,6 +130,7 @@ var (
ServiceBus: "https://servicebus.azure.net/",
SQLDatabase: "https://database.windows.net/",
CosmosDB: "https://cosmos.azure.com",
ManagedHSM: "https://managedhsm.azure.net",
},
}

Expand All @@ -138,6 +144,7 @@ var (
ActiveDirectoryEndpoint: "https://login.microsoftonline.us/",
GalleryEndpoint: "https://gallery.usgovcloudapi.net/",
KeyVaultEndpoint: "https://vault.usgovcloudapi.net/",
ManagedHSMEndpoint: NotAvailable,
GraphEndpoint: "https://graph.windows.net/",
ServiceBusEndpoint: "https://servicebus.usgovcloudapi.net/",
BatchManagementEndpoint: "https://batch.core.usgovcloudapi.net/",
Expand All @@ -149,6 +156,7 @@ var (
SQLDatabaseDNSSuffix: "database.usgovcloudapi.net",
TrafficManagerDNSSuffix: "usgovtrafficmanager.net",
KeyVaultDNSSuffix: "vault.usgovcloudapi.net",
ManagedHSMDNSSuffix: NotAvailable,
ServiceBusEndpointSuffix: "servicebus.usgovcloudapi.net",
ServiceManagementVMDNSSuffix: "usgovcloudapp.net",
ResourceManagerVMDNSSuffix: "cloudapp.usgovcloudapi.net",
Expand All @@ -168,6 +176,7 @@ var (
ServiceBus: "https://servicebus.azure.net/",
SQLDatabase: "https://database.usgovcloudapi.net/",
CosmosDB: "https://cosmos.azure.com",
ManagedHSM: NotAvailable,
},
}

Expand All @@ -181,6 +190,7 @@ var (
ActiveDirectoryEndpoint: "https://login.chinacloudapi.cn/",
GalleryEndpoint: "https://gallery.chinacloudapi.cn/",
KeyVaultEndpoint: "https://vault.azure.cn/",
ManagedHSMEndpoint: NotAvailable,
GraphEndpoint: "https://graph.chinacloudapi.cn/",
ServiceBusEndpoint: "https://servicebus.chinacloudapi.cn/",
BatchManagementEndpoint: "https://batch.chinacloudapi.cn/",
Expand All @@ -192,6 +202,7 @@ var (
SQLDatabaseDNSSuffix: "database.chinacloudapi.cn",
TrafficManagerDNSSuffix: "trafficmanager.cn",
KeyVaultDNSSuffix: "vault.azure.cn",
ManagedHSMDNSSuffix: NotAvailable,
ServiceBusEndpointSuffix: "servicebus.chinacloudapi.cn",
ServiceManagementVMDNSSuffix: "chinacloudapp.cn",
ResourceManagerVMDNSSuffix: "cloudapp.chinacloudapi.cn",
Expand All @@ -211,6 +222,7 @@ var (
ServiceBus: "https://servicebus.azure.net/",
SQLDatabase: "https://database.chinacloudapi.cn/",
CosmosDB: "https://cosmos.azure.com",
ManagedHSM: NotAvailable,
},
}

Expand All @@ -224,6 +236,7 @@ var (
ActiveDirectoryEndpoint: "https://login.microsoftonline.de/",
GalleryEndpoint: "https://gallery.cloudapi.de/",
KeyVaultEndpoint: "https://vault.microsoftazure.de/",
ManagedHSMEndpoint: NotAvailable,
GraphEndpoint: "https://graph.cloudapi.de/",
ServiceBusEndpoint: "https://servicebus.cloudapi.de/",
BatchManagementEndpoint: "https://batch.cloudapi.de/",
Expand All @@ -235,6 +248,7 @@ var (
SQLDatabaseDNSSuffix: "database.cloudapi.de",
TrafficManagerDNSSuffix: "azuretrafficmanager.de",
KeyVaultDNSSuffix: "vault.microsoftazure.de",
ManagedHSMDNSSuffix: NotAvailable,
ServiceBusEndpointSuffix: "servicebus.cloudapi.de",
ServiceManagementVMDNSSuffix: "azurecloudapp.de",
ResourceManagerVMDNSSuffix: "cloudapp.microsoftazure.de",
Expand All @@ -254,6 +268,7 @@ var (
ServiceBus: "https://servicebus.azure.net/",
SQLDatabase: "https://database.cloudapi.de/",
CosmosDB: "https://cosmos.azure.com",
ManagedHSM: NotAvailable,
},
}
)
Expand Down
18 changes: 17 additions & 1 deletion autorest/azure/environments_test.go
Expand Up @@ -35,6 +35,7 @@ const (
opInsightsResourceID = "--operational-insights-resource-id--"
ossRDBMSResourceID = "--oss-rdbms-resource-id--"
cosmosDBResourceID = "--cosmosdb-resource-id--"
managedHSMResourceID = "--managed-hsm-resource-id--"
)

// This correlates to the expected contents of ./testdata/test_environment_1.json
Expand All @@ -47,6 +48,7 @@ var testEnvironment1 = Environment{
ActiveDirectoryEndpoint: "--active-directory-endpoint--",
GalleryEndpoint: "--gallery-endpoint--",
KeyVaultEndpoint: "--key-vault--endpoint--",
ManagedHSMEndpoint: "--managed-hsm-endpoint--",
GraphEndpoint: "--graph-endpoint--",
StorageEndpointSuffix: "--storage-endpoint-suffix--",
CosmosDBDNSSuffix: "--cosmos-db-dns-suffix--",
Expand All @@ -56,6 +58,7 @@ var testEnvironment1 = Environment{
SQLDatabaseDNSSuffix: "--sql-database-dns-suffix--",
TrafficManagerDNSSuffix: "--traffic-manager-dns-suffix--",
KeyVaultDNSSuffix: "--key-vault-dns-suffix--",
ManagedHSMDNSSuffix: "--managed-hsm-dns-suffix--",
ServiceBusEndpointSuffix: "--service-bus-endpoint-suffix--",
ServiceManagementVMDNSSuffix: "--asm-vm-dns-suffix--",
ResourceManagerVMDNSSuffix: "--arm-vm-dns-suffix--",
Expand All @@ -69,6 +72,7 @@ var testEnvironment1 = Environment{
OperationalInsights: opInsightsResourceID,
OSSRDBMS: ossRDBMSResourceID,
CosmosDB: cosmosDBResourceID,
ManagedHSM: managedHSMResourceID,
},
}

Expand Down Expand Up @@ -207,6 +211,8 @@ func TestDeserializeEnvironment(t *testing.T) {
"serviceBusEndpoint": "--service-bus-endpoint--",
"keyVaultDNSSuffix": "--key-vault-dns-suffix--",
"keyVaultEndpoint": "--key-vault-endpoint--",
"managedHSMDNSSuffix": "--managed-hsm-dns-suffix--",
"managedHSMEndpoint": "--managed-hsm-endpoint--",
"managementPortalURL": "--management-portal-url--",
"publishSettingsURL": "--publish-settings-url--",
"resourceManagerEndpoint": "--resource-manager-endpoint--",
Expand All @@ -229,7 +235,8 @@ func TestDeserializeEnvironment(t *testing.T) {
"keyVault": "` + keyvaultResourceID + `",
"operationalInsights": "` + opInsightsResourceID + `",
"ossRDBMS": "` + ossRDBMSResourceID + `",
"cosmosDB": "` + cosmosDBResourceID + `"
"cosmosDB": "` + cosmosDBResourceID + `",
"managedHSM": "` + managedHSMResourceID + `"
}
}`

Expand Down Expand Up @@ -263,6 +270,9 @@ func TestDeserializeEnvironment(t *testing.T) {
if "--key-vault-endpoint--" != testSubject.KeyVaultEndpoint {
t.Errorf("Expected KeyVaultEndpoint to be \"--key-vault-endpoint--\", but got %q", testSubject.KeyVaultEndpoint)
}
if "--managed-hsm-endpoint--" != testSubject.ManagedHSMEndpoint {
t.Errorf("Expected ManagedHSMEndpoint to be \"--managed-hsm-endpoint--\", but got %q", testSubject.ManagedHSMEndpoint)
}
if "--service-bus-endpoint--" != testSubject.ServiceBusEndpoint {
t.Errorf("Expected ServiceBusEndpoint to be \"--service-bus-endpoint--\", but goet %q", testSubject.ServiceBusEndpoint)
}
Expand Down Expand Up @@ -290,6 +300,9 @@ func TestDeserializeEnvironment(t *testing.T) {
if "--key-vault-dns-suffix--" != testSubject.KeyVaultDNSSuffix {
t.Errorf("Expected StorageEndpointSuffix to be \"--key-vault-dns-suffix--\", but got %q", testSubject.KeyVaultDNSSuffix)
}
if "--managed-hsm-dns-suffix--" != testSubject.ManagedHSMDNSSuffix {
t.Errorf("Expected StorageEndpointSuffix to be \"--managed-hsm-dns-suffix--\", but got %q", testSubject.ManagedHSMDNSSuffix)
}
if "--service-bus-endpoint-suffix--" != testSubject.ServiceBusEndpointSuffix {
t.Errorf("Expected StorageEndpointSuffix to be \"--service-bus-endpoint-suffix--\", but got %q", testSubject.ServiceBusEndpointSuffix)
}
Expand Down Expand Up @@ -323,6 +336,9 @@ func TestDeserializeEnvironment(t *testing.T) {
if cosmosDBResourceID != testSubject.ResourceIdentifiers.CosmosDB {
t.Errorf("Expected ResourceIdentifiers.CosmosDB to be "+cosmosDBResourceID+", but got %q", testSubject.ResourceIdentifiers.CosmosDB)
}
if managedHSMResourceID != testSubject.ResourceIdentifiers.ManagedHSM {
t.Errorf("Expected ResourceIdentifiers.ManagedHSM to be "+managedHSMResourceID+", but got %q", testSubject.ResourceIdentifiers.ManagedHSM)
}
}

func TestRoundTripSerialization(t *testing.T) {
Expand Down
6 changes: 5 additions & 1 deletion autorest/azure/testdata/test_environment_1.json
Expand Up @@ -7,6 +7,7 @@
"activeDirectoryEndpoint": "--active-directory-endpoint--",
"galleryEndpoint": "--gallery-endpoint--",
"keyVaultEndpoint": "--key-vault--endpoint--",
"managedHSMEndpoint": "--managed-hsm-endpoint--",
"graphEndpoint": "--graph-endpoint--",
"storageEndpointSuffix": "--storage-endpoint-suffix--",
"cosmosDBDNSSuffix": "--cosmos-db-dns-suffix--",
Expand All @@ -16,6 +17,7 @@
"sqlDatabaseDNSSuffix": "--sql-database-dns-suffix--",
"trafficManagerDNSSuffix": "--traffic-manager-dns-suffix--",
"keyVaultDNSSuffix": "--key-vault-dns-suffix--",
"managedHSMDNSSuffix": "--managed-hsm-dns-suffix--",
"serviceBusEndpointSuffix": "--service-bus-endpoint-suffix--",
"serviceManagementVMDNSSuffix": "--asm-vm-dns-suffix--",
"resourceManagerVMDNSSuffix": "--arm-vm-dns-suffix--",
Expand All @@ -28,6 +30,8 @@
"keyVault": "--keyvault-resource-id--",
"operationalInsights": "--operational-insights-resource-id--",
"ossRDBMS": "--oss-rdbms-resource-id--",
"cosmosDB": "--cosmosdb-resource-id--"
"cosmosDB": "--cosmosdb-resource-id--",
"managedHSM": "--managed-hsm-resource-id--"
}
}