Skip to content

Commit

Permalink
remove unneccessary transformation of paths in get_services.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Dec 17, 2024
1 parent cc29570 commit 18aa211
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import vcs_roots.HashiCorpVCSRootBeta
import vcs_roots.HashiCorpVCSRootGa
import vcs_roots.ModularMagicianVCSRootBeta
import vcs_roots.ModularMagicianVCSRootGa
import getServicesList
import components.projects.feature_branches.getServicesList

const val featureBranchEphemeralWriteOnly = "FEATURE-BRANCH-ephemeral-write-only"
const val EphemeralWriteOnlyTfCoreVersion = "1.11.0-alpha20241211"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
package components.projects.feature_branches

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")
Expand All @@ -24,32 +27,30 @@ fun getServicesList(Services: Array<String>, version: String): Map<String,Map<St
}

when (version) {
"GA" -> return servicesList
"GA" -> servicesList
"Beta" -> {
servicesList = servicesList.mapValues { (_, value) ->
servicesList.mapValues { (_, value) ->
value + mapOf(
"displayName" to "${value["displayName"]} - Beta",
"path" to (value["path"]?.replace("./google/", "./google-beta/") ?: "")
"displayName" to "${value["displayName"]} - Beta"
)
}.toMutableMap()
}
"GA-MM" -> {
servicesList = servicesList.mapValues { (_, value) ->
servicesList.mapValues { (_, value) ->
value + mapOf(
"displayName" to "${value["displayName"]} - MM"
"displayName" to "${value["displayName"]} - MM"
)
}.toMutableMap()
}
"Beta-MM" -> {
servicesList = servicesList.mapValues { (_, value) ->
servicesList.mapValues { (_, value) ->
value + mapOf(
"displayName" to "${value["displayName"]} - Beta - MM",
"path" to (value["path"]?.replace("./google-beta/", "./google-beta/services/") ?: "")
"displayName" to "${value["displayName"]} - Beta - MM"
)
}.toMutableMap()
}
else -> throw Exception("Invalid version $version")
}
}.also { servicesList = it as MutableMap<String, Map<String, String>> }

return servicesList
}

0 comments on commit 18aa211

Please sign in to comment.