in common/src/main/kotlin/org/jetbrains/teamcity/vault/gcp/GcpAuthenticationHandler.kt [60:76]
fun gcpIamCredentialsAuthentication(
gcpIamAuth: Auth.GcpIamAuth,
template: RestTemplate
): GcpIamCredentialsAuthentication {
val gcpAuthOptions =
GcpIamCredentialsAuthenticationOptions.builder()
.role(gcpIamAuth.role)
.path(gcpIamAuth.endpointPath)
.credentials(GoogleCredentials.getApplicationDefault())
val serviceAccId = gcpIamAuth.serviceAccount
if (serviceAccId.isNotEmpty()) {
gcpAuthOptions.serviceAccountId(serviceAccId)
}
return GcpIamCredentialsAuthentication(gcpAuthOptions.build(), template)
}