2020-04-08 16:37:14 +03:00
|
|
|
package azureclient
|
|
|
|
|
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the Apache License 2.0.
|
|
|
|
|
2020-03-31 08:20:20 +03:00
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2024-07-12 22:07:46 +03:00
|
|
|
// This map stores the versions of different Azure APIs to be used in generated ARM templates in various
|
|
|
|
// parts of the codebase. The versions used here do not necessarily align with the API versions used in the
|
|
|
|
// Go client wrappers defined in pkg/util/azureclient/mgmt and pkg/util/azureclient/azuresdk.
|
|
|
|
// Keys must be lower case.
|
2020-11-11 23:06:37 +03:00
|
|
|
var apiVersions = map[string]string{
|
2022-11-09 02:44:00 +03:00
|
|
|
"microsoft.authorization": "2018-09-01-preview",
|
|
|
|
"microsoft.authorization/denyassignments": "2018-07-01-preview",
|
|
|
|
"microsoft.authorization/roledefinitions": "2018-01-01-preview",
|
Replace the compute API version with the latest stable version
For context, this version needs to be replaced because I encountered an
error while trying to deploy shared RP dev infra that indicates that the
2021-12-01 version somehow doesn't exist anymore:
DeploymentWhatIfResourceError - The request to predict template deployment changes to scope '/subscriptions/redacted-sub-id/resourceGroups/v4-westeurope' has failed due to a resource error. See details for more information.
NoRegisteredProviderFound - No registered resource provider found for location 'westeurope' and API version '2021-12-01' for type 'virtualMachineScaleSets'. The supported api-versions are '2015-05-01-preview, 2015-06-15, 2016-03-30, 2016-04-30-preview, 2016-08-30, 2017-03-30, 2017-10-30-preview, 2017-12-01, 2018-04-01, 2018-06-01, 2018-10-01, 2019-03-01, 2019-07-01, 2019-12-01, 2020-06-01, 2020-12-01, 2021-03-01, 2021-04-01, 2021-07-01, 2021-11-01, 2022-03-01, 2022-08-01, 2022-11-01, 2023-03-01, 2023-07-01, 2023-09-01, 2024-03-01, 2024-07-01'. The supported locations are 'eastus, eastus2, westus, centralus, northcentralus, southcentralus, northeurope, westeurope, eastasia, southeastasia, japaneast, japanwest, australiaeast, australiasoutheast, australiacentral, brazilsouth, southindia, centralindia, westindia, canadacentral, canadaeast, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral, southafricanorth, uaenorth, switzerlandnorth, germanywestcentral, norwayeast, jioindiawest, westus3, swedencentral, qatarcentral, polandcentral, italynorth, israelcentral, spaincentral, mexicocentral, brazilsoutheast'.
2024-07-12 22:05:48 +03:00
|
|
|
"microsoft.compute": "2024-03-01",
|
2023-07-21 19:15:57 +03:00
|
|
|
"microsoft.compute/diskencryptionsets": "2021-04-01",
|
2022-11-09 02:44:00 +03:00
|
|
|
"microsoft.compute/disks": "2019-03-01",
|
2023-07-21 19:15:57 +03:00
|
|
|
"microsoft.compute/galleries": "2022-03-03",
|
2022-11-09 02:44:00 +03:00
|
|
|
"microsoft.compute/snapshots": "2020-05-01",
|
|
|
|
"microsoft.containerregistry": "2020-11-01-preview",
|
2022-11-14 08:17:43 +03:00
|
|
|
"microsoft.resources/deployments": "2021-04-01",
|
2024-04-29 08:08:24 +03:00
|
|
|
"microsoft.documentdb": "2023-04-15",
|
2022-11-09 02:44:00 +03:00
|
|
|
"microsoft.insights": "2018-03-01",
|
|
|
|
"microsoft.keyvault": "2019-09-01",
|
|
|
|
"microsoft.keyvault/vaults/accesspolicies": "2021-10-01",
|
|
|
|
"microsoft.managedidentity": "2018-11-30",
|
|
|
|
"microsoft.network": "2020-08-01",
|
|
|
|
"microsoft.network/dnszones": "2018-05-01",
|
|
|
|
"microsoft.network/privatednszones": "2018-09-01",
|
2024-06-18 22:42:02 +03:00
|
|
|
"microsoft.storage": "2021-09-01",
|
2020-04-08 16:37:14 +03:00
|
|
|
}
|
2020-03-31 08:20:20 +03:00
|
|
|
|
2020-11-11 23:06:37 +03:00
|
|
|
// APIVersion gets the APIVersion from a full resource type
|
|
|
|
func APIVersion(typ string) string {
|
|
|
|
t := strings.ToLower(typ)
|
2020-04-09 06:35:33 +03:00
|
|
|
|
|
|
|
for {
|
2020-11-11 23:06:37 +03:00
|
|
|
if apiVersion, ok := apiVersions[t]; ok {
|
|
|
|
return apiVersion
|
2020-03-31 08:20:20 +03:00
|
|
|
}
|
2020-04-09 06:35:33 +03:00
|
|
|
|
|
|
|
i := strings.LastIndexByte(t, '/')
|
|
|
|
if i == -1 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
t = t[:i]
|
2020-03-31 08:20:20 +03:00
|
|
|
}
|
|
|
|
|
2020-11-11 23:06:37 +03:00
|
|
|
return ""
|
2020-03-31 08:20:20 +03:00
|
|
|
}
|