Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add domain name to the connector config. #2098

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

hessjcg
Copy link
Collaborator

@hessjcg hessjcg commented Jan 9, 2025

Add DomainName to connection config, and an InstanceNameResolver function. This will allow the connector
to be configured using a domain name referencing the instead of the instance name.

This is part of the implementation of #2043.

See #2043 for the whole feature definition.

@hessjcg hessjcg marked this pull request as ready for review January 10, 2025 18:16
@hessjcg hessjcg requested a review from a team as a code owner January 10, 2025 18:16
Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM but let's also get someone more experienced at Java to review it as well

@pandirigoog

This comment was marked as resolved.

@hessjcg hessjcg force-pushed the gh-2043-config-domain-name branch 3 times, most recently from cf8fc9d to 0bd57d4 Compare January 14, 2025 22:49
this.connectionName = connectionName;
this.domainName = domainName;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to validate it with some DOMAIN_NAME matcher ? generic DNS name or something ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I added a Regex to validate the domain name.

@@ -154,6 +157,37 @@ ConnectionInfoCache getConnection(ConnectionConfig config) {
return instance;
}

private ConnectionConfig resolveConnectionName(ConnectionConfig config) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know its private method (so method documentation is optional) but I think this method is important enough that it requires some explanation. Like cloudSqlInstance is prioritized over domainName when both are set etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -131,6 +131,50 @@ public void create_successfulPrivateConnection() throws IOException, Interrupted
assertThat(readLine(socket)).isEqualTo(SERVER_MESSAGE);
}

@Test
public void create_successfulPublicConnectionWithDomainName()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a test for both domainName and cloudSqlInstance set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@hessjcg hessjcg force-pushed the gh-2043-config-domain-name branch 3 times, most recently from 2685a44 to 14f7483 Compare January 17, 2025 18:58
@hessjcg hessjcg force-pushed the gh-2043-config-domain-name branch from 14f7483 to 9536668 Compare January 23, 2025 18:14
@hessjcg hessjcg enabled auto-merge (squash) January 23, 2025 18:15
@hessjcg hessjcg merged commit d747360 into main Jan 23, 2025
17 checks passed
@hessjcg hessjcg deleted the gh-2043-config-domain-name branch January 23, 2025 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants