in core/src/main/java/com/google/cloud/sql/core/Connector.java [186:206]
private ConnectionConfig resolveConnectionName(ConnectionConfig config) {
// If domainName is not set, return the original configuration unmodified.
if (Strings.isNullOrEmpty(config.getDomainName())) {
return config;
}
// If both domainName and cloudSqlInstance are set, ignore the domain name. Return a new
// configuration with domainName set to null.
if (!Strings.isNullOrEmpty(config.getCloudSqlInstance())) {
return config.withDomainName(null);
}
// If only domainName is set, resolve the domain name.
try {
final CloudSqlInstanceName name = resolveDomain(config);
return config.withCloudSqlInstance(name.getConnectionName());
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
String.format("Cloud SQL connection name is invalid: \"%s\"", config.getDomainName()), e);
}
}