From 77ecdfe87eb42372c16d07684c27d68c0ae87fc4 Mon Sep 17 00:00:00 2001 From: Anish Ramasekar Date: Wed, 30 Mar 2022 17:14:28 +0000 Subject: [PATCH] Add ManagedHSM endpoint and resource id ref: https://docs.microsoft.com/en-us/azure/key-vault/general/about-keys-secrets-certificates ManagedHSM is only supported in AzurePublicCloud. Signed-off-by: Anish Ramasekar --- autorest/azure/environments.go | 15 +++++++++++++++ autorest/azure/environments_test.go | 18 +++++++++++++++++- .../azure/testdata/test_environment_1.json | 6 +++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/autorest/azure/environments.go b/autorest/azure/environments.go index 737950eb3..e19ea7556 100644 --- a/autorest/azure/environments.go +++ b/autorest/azure/environments.go @@ -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. @@ -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"` @@ -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"` @@ -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/", @@ -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", @@ -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", }, } @@ -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/", @@ -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", @@ -168,6 +176,7 @@ var ( ServiceBus: "https://servicebus.azure.net/", SQLDatabase: "https://database.usgovcloudapi.net/", CosmosDB: "https://cosmos.azure.com", + ManagedHSM: NotAvailable, }, } @@ -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/", @@ -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", @@ -211,6 +222,7 @@ var ( ServiceBus: "https://servicebus.azure.net/", SQLDatabase: "https://database.chinacloudapi.cn/", CosmosDB: "https://cosmos.azure.com", + ManagedHSM: NotAvailable, }, } @@ -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/", @@ -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", @@ -254,6 +268,7 @@ var ( ServiceBus: "https://servicebus.azure.net/", SQLDatabase: "https://database.cloudapi.de/", CosmosDB: "https://cosmos.azure.com", + ManagedHSM: NotAvailable, }, } ) diff --git a/autorest/azure/environments_test.go b/autorest/azure/environments_test.go index 30f1135c5..923e04bde 100644 --- a/autorest/azure/environments_test.go +++ b/autorest/azure/environments_test.go @@ -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 @@ -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--", @@ -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--", @@ -69,6 +72,7 @@ var testEnvironment1 = Environment{ OperationalInsights: opInsightsResourceID, OSSRDBMS: ossRDBMSResourceID, CosmosDB: cosmosDBResourceID, + ManagedHSM: managedHSMResourceID, }, } @@ -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--", @@ -229,7 +235,8 @@ func TestDeserializeEnvironment(t *testing.T) { "keyVault": "` + keyvaultResourceID + `", "operationalInsights": "` + opInsightsResourceID + `", "ossRDBMS": "` + ossRDBMSResourceID + `", - "cosmosDB": "` + cosmosDBResourceID + `" + "cosmosDB": "` + cosmosDBResourceID + `", + "managedHSM": "` + managedHSMResourceID + `" } }` @@ -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) } @@ -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) } @@ -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) { diff --git a/autorest/azure/testdata/test_environment_1.json b/autorest/azure/testdata/test_environment_1.json index b5b842b3a..c23bda399 100644 --- a/autorest/azure/testdata/test_environment_1.json +++ b/autorest/azure/testdata/test_environment_1.json @@ -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--", @@ -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--", @@ -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--" } } +