Skip to content

Commit c60bcb2

Browse files
authored
Append the API version to all requests if set (#1514)
* Append the API version to all requests if set * Use older API version
1 parent cd69879 commit c60bcb2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerCmdExecFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public InvocationBuilder request() {
7979
resource = "/" + resource;
8080
}
8181

82+
RemoteApiVersion apiVersion = getDockerClientConfig().getApiVersion();
83+
if (apiVersion != RemoteApiVersion.UNKNOWN_VERSION) {
84+
resource = "/" + apiVersion.asWebPathPart() + resource;
85+
}
86+
8287
if (!queryParams.isEmpty()) {
8388
Escaper urlFormParameterEscaper = UrlEscapers.urlFormParameterEscaper();
8489
resource = queryParams.asMap().entrySet().stream()

docker-java/src/test/java/com/github/dockerjava/core/DockerRule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ private static DefaultDockerClientConfig config() {
178178

179179
public static DefaultDockerClientConfig config(String password) {
180180
DefaultDockerClientConfig.Builder builder = DefaultDockerClientConfig.createDefaultConfigBuilder()
181+
.withApiVersion(RemoteApiVersion.VERSION_1_30)
181182
.withRegistryUrl("https://index.docker.io/v1/");
182183
if (password != null) {
183184
builder = builder.withRegistryPassword(password);

0 commit comments

Comments
 (0)