-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow setting database name and user when using JDBC URL #594
Changes from 14 commits
63343fe
6a1726a
6f151da
6daa5b0
8e313f1
b3d290a
ffb84f4
4006d4f
c10f4b6
d807546
1be1c16
d6dcc89
5d8f12a
f162081
8fde60e
e29a339
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,9 @@ node_modules/ | |
|
||
.gradle/ | ||
build/ | ||
|
||
# Eclipse IDE files | ||
**/.project | ||
**/.classpath | ||
**/.settings | ||
**/bin/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,10 @@ protected boolean isApplicable() { | |
return true; | ||
} | ||
|
||
protected boolean isPersistable() { | ||
return true; | ||
} | ||
|
||
/** | ||
* @return highest to lowest priority value | ||
*/ | ||
|
@@ -93,7 +97,10 @@ public static DockerClientProviderStrategy getFirstValidStrategy(List<DockerClie | |
LOGGER.warn("Can't instantiate a strategy from {}", it, e); | ||
return Stream.empty(); | ||
} | ||
}), | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the formatting in this Stream.concat... block just 'idea' being weird? doesnt seem to follow the 4 space indents everywhere else. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is not modified and related for this PR, probably upstream has changed and so you see the difference. I would leave it as-is for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
// Ignore persisted strategy if it's not persistable anymore | ||
.filter(DockerClientProviderStrategy::isPersistable) | ||
.peek(strategy -> LOGGER.info("Loaded {} from ~/.testcontainers.properties, will try it first", strategy.getClass().getName())), | ||
strategies | ||
.stream() | ||
.filter(DockerClientProviderStrategy::isApplicable) | ||
|
@@ -104,7 +111,9 @@ public static DockerClientProviderStrategy getFirstValidStrategy(List<DockerClie | |
strategy.test(); | ||
LOGGER.info("Found Docker environment with {}", strategy.getDescription()); | ||
|
||
TestcontainersConfiguration.getInstance().updateGlobalConfig("docker.client.strategy", strategy.getClass().getName()); | ||
if (strategy.isPersistable()) { | ||
TestcontainersConfiguration.getInstance().updateGlobalConfig("docker.client.strategy", strategy.getClass().getName()); | ||
} | ||
|
||
return Stream.of(strategy); | ||
} catch (Exception | ExceptionInInitializerError | NoClassDefFoundError e) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
package org.testcontainers.containers; | ||
|
||
import org.testcontainers.jdbc.ConnectionUrl; | ||
|
||
/** | ||
* Base class for classes that can provide a JDBC container. | ||
*/ | ||
public abstract class JdbcDatabaseContainerProvider { | ||
|
||
/** | ||
* Tests if the specified database type is supported by this Container Provider. It should match to the base image name. | ||
* @param databaseType {@link String} | ||
* @return <code>true</code> when provider can handle this database type, else <code>false</code>. | ||
*/ | ||
public abstract boolean supports(String databaseType); | ||
|
||
/** | ||
* Instantiate a new {@link JdbcDatabaseContainer} with specified image tag. | ||
* @param tag | ||
* @return Instance of {@link JdbcDatabaseContainer} | ||
*/ | ||
public abstract JdbcDatabaseContainer newInstance(String tag); | ||
|
||
/** | ||
* Instantiate a new {@link JdbcDatabaseContainer} using information provided with {@link ConnectionUrl}. | ||
* @param url {@link ConnectionUrl} | ||
* @return Instance of {@link JdbcDatabaseContainer} | ||
*/ | ||
public JdbcDatabaseContainer newInstance(ConnectionUrl url) { | ||
return newInstance(url.getImageTag()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you update the changelog to describe this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated Changelog with items that I feel related to this PR. Please take a look and let me know/feel free to modify as you seem right.