Skip to content

Commit

Permalink
Mark DockerMachineClientProviderStrategy as not persistable (#593)
Browse files Browse the repository at this point in the history
* Mark DockerMachineClientProviderStrategy as not persistable

* Update CHANGELOG.md
  • Loading branch information
bsideup committed Feb 26, 2018
1 parent 242605a commit 6f151da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
### Changed
- Abstracted and changed database init script functionality to support use of SQL-like scripts with non-JDBC connections. ([\#551](https://github.com/testcontainers/testcontainers-java/pull/551))
- Added `JdbcDatabaseContainer(Future)` constructor. ([\#543](https://github.com/testcontainers/testcontainers-java/issues/543))
- Mark DockerMachineClientProviderStrategy as not persistable ([\#593](https://github.com/testcontainers/testcontainers-java/pull/593))

## [1.6.0] - 2018-01-28

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ protected boolean isApplicable() {
return true;
}

protected boolean isPersistable() {
return true;
}

/**
* @return highest to lowest priority value
*/
Expand Down Expand Up @@ -93,7 +97,10 @@ public static DockerClientProviderStrategy getFirstValidStrategy(List<DockerClie
LOGGER.warn("Can't instantiate a strategy from {}", it, e);
return Stream.empty();
}
}),
})
// 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)
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ protected boolean isApplicable() {
return DockerMachineClient.instance().isInstalled();
}

@Override
protected boolean isPersistable() {
return false;
}

@Override
protected int getPriority() {
return ProxiedUnixSocketClientProviderStrategy.PRIORITY - 10;
Expand Down

0 comments on commit 6f151da

Please sign in to comment.