Skip to content

Commit

Permalink
chore: Use domain name from R2DBC connections when configuring the co…
Browse files Browse the repository at this point in the history
…nnector.
  • Loading branch information
hessjcg committed Jan 17, 2025
1 parent bbf8156 commit 0f1d338
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,22 @@ public ConnectionFactory create(ConnectionFactoryOptions connectionFactoryOption
? RefreshStrategy.LAZY
: RefreshStrategy.BACKGROUND;

final String r2dbcHostname = (String) connectionFactoryOptions.getRequiredValue(HOST);
final String cloudSqlInstance;
final String domainName;
if (CloudSqlInstanceName.isValidInstanceName(r2dbcHostname)) {
cloudSqlInstance = r2dbcHostname;
domainName = null;
} else {
cloudSqlInstance = null;
domainName = r2dbcHostname;
}

Builder optionBuilder = createBuilder(connectionFactoryOptions);
String cloudSqlInstance = (String) connectionFactoryOptions.getRequiredValue(HOST);
ConnectionConfig config =
new ConnectionConfig.Builder()
.withCloudSqlInstance(cloudSqlInstance)
.withDomainName(domainName)
.withAuthType(enableIamAuth ? AuthType.IAM : AuthType.PASSWORD)
.withIpTypes(ipTypes)
.withNamedConnector(namedConnector)
Expand Down

0 comments on commit 0f1d338

Please sign in to comment.