Skip to content

Commit

Permalink
Add support for the AWS Secrets Manager JDBC URLs (#9335)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek committed Aug 29, 2023
1 parent 68da349 commit d140cf9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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()
}
}

0 comments on commit d140cf9

Please sign in to comment.