-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove unneccessary transformation of paths in get_services.kt
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
mmv1/third_party/terraform/.teamcity/components/projects/feature_branches/get_services.kt
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,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<String>, version: String): Map<String,Map<String,String>> { | ||
if (Services.isEmpty()) { | ||
throw Exception("No services found for version $version") | ||
} | ||
|
||
var servicesList = mutableMapOf<String,Map<String,String>>() | ||
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<String, Map<String, String>> } | ||
|
||
return servicesList | ||
} |