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

Add support for the AWS Secrets Manager JDBC URLs #9335

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,15 @@ public static DbInfo parse(String connectionUrl, Properties props) {
// Make this easier and ignore case.
connectionUrl = connectionUrl.toLowerCase(Locale.ROOT);

if (!connectionUrl.startsWith("jdbc:")) {
String jdbcUrl;
if (connectionUrl.startsWith("jdbc:")) {
jdbcUrl = connectionUrl.substring("jdbc:".length());
} else if (connectionUrl.startsWith("jdbc-secretsmanager:")) {
jdbcUrl = connectionUrl.substring("jdbc-secretsmanager:".length());
} else {
return DEFAULT;
}

String jdbcUrl = connectionUrl.substring("jdbc:".length());
int typeLoc = jdbcUrl.indexOf(':');

if (typeLoc < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ class JdbcConnectionUrlParserTest extends Specification {
"jdbc:tibcosoftware:postgresql://server_name:5432;DatabaseName=dbname" | null | "tibcosoftware:postgresql://server_name:5432" | "postgresql" | "postgresql" | null | "server_name" | 5432 | null | "dbname"
"jdbc:tibcosoftware:db2://server_name:50000;DatabaseName=dbname" | null | "tibcosoftware:db2://server_name:50000" | "db2" | "db2" | null | "server_name" | 50000 | null | "dbname"

// https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_jdbc.html
"jdbc-secretsmanager:mysql://example.com:50000" | null | "mysql://example.com:50000" | "mysql" | null | null | "example.com" | 50000 | null | null
"jdbc-secretsmanager:postgresql://example.com:50000/dbname" | null | "postgresql://example.com:50000" | "postgresql" | null | null | "example.com" | 50000 | null | "dbname"
"jdbc-secretsmanager:oracle:thin:@example.com:50000/ORCL" | null | "oracle:thin://example.com:50000" | "oracle" | "thin" | null | "example.com" | 50000 | "orcl" | null
"jdbc-secretsmanager:sqlserver://example.com:50000" | null | "sqlserver://example.com:50000" | "mssql" | null | null | "example.com" | 50000 | null | null

expected = DbInfo.builder().system(system).subtype(subtype).user(user).name(name).db(db).host(host).port(port).shortUrl(shortUrl).build()
}
}