diff --git a/mmv1/third_party/terraform/.teamcity/components/projects/feature_branches/get_services.kt b/mmv1/third_party/terraform/.teamcity/components/projects/feature_branches/get_services.kt new file mode 100644 index 000000000000..ac0d3951bc0e --- /dev/null +++ b/mmv1/third_party/terraform/.teamcity/components/projects/feature_branches/get_services.kt @@ -0,0 +1,54 @@ +/* + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ +import generated.ServicesListGa +import generated.ServicesListBeta + +// This file is maintained in the GoogleCloudPlatform/magic-modules repository and copied into the downstream provider repositories. Any changes to this file in the downstream will be overwritten. + +// This function is used to get the services list for a given version. Typically used in feature branch builds for testing very specific services only. +fun getServicesList(Services: Array, version: String): Map> { + if (Services.isEmpty()) { + throw Exception("No services found for version $version") + } + + var servicesList = mutableMapOf>() + for (service in Services) { + if (version == "GA" || version == "GA-MM") { + servicesList[service] = ServicesListGa.getOrElse(service) { throw Exception("Service $service not found") } + } else if (version == "Beta" || version == "Beta-MM") { + servicesList[service] = ServicesListBeta.getOrElse(service) { throw Exception("Service $service not found") } + } else { + throw Exception("Invalid version $version") + } + } + + when (version) { + "GA" -> servicesList + "Beta" -> { + servicesList.mapValues { (_, value) -> + value + mapOf( + "displayName" to "${value["displayName"]} - Beta" + ) + }.toMutableMap() + } + "GA-MM" -> { + servicesList.mapValues { (_, value) -> + value + mapOf( + "displayName" to "${value["displayName"]} - MM" + ) + }.toMutableMap() + } + "Beta-MM" -> { + servicesList.mapValues { (_, value) -> + value + mapOf( + "displayName" to "${value["displayName"]} - Beta - MM" + ) + }.toMutableMap() + } + else -> throw Exception("Invalid version $version") + }.also { servicesList = it as MutableMap> } + + return servicesList +} \ No newline at end of file