| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | import com.github.dockerjava.api.model.AuthConfigurations; | |
| 6 | 6 | import com.github.dockerjava.core.NameParser.HostnameReposName; | |
| 7 | 7 | import com.github.dockerjava.core.NameParser.ReposTag; | |
| 8 | + import java.util.Optional; | ||
| 8 | 9 | import org.apache.commons.lang3.StringUtils; | |
| 9 | 10 | import org.apache.commons.lang3.SystemUtils; | |
| 10 | 11 | import org.apache.commons.lang3.builder.EqualsBuilder; | |
@@ -37,6 +38,8 @@ public class DefaultDockerClientConfig implements Serializable, DockerClientConf | |||
| 37 | 38 | ||
| 38 | 39 | public static final String DOCKER_HOST = "DOCKER_HOST"; | |
| 39 | 40 | ||
| 41 | + public static final String DOCKER_CONTEXT = "DOCKER_CONTEXT"; | ||
| 42 | + | ||
| 40 | 43 | public static final String DOCKER_TLS_VERIFY = "DOCKER_TLS_VERIFY"; | |
| 41 | 44 | ||
| 42 | 45 | public static final String DOCKER_CONFIG = "DOCKER_CONFIG"; | |
@@ -87,11 +90,13 @@ public class DefaultDockerClientConfig implements Serializable, DockerClientConf | |||
| 87 | 90 | ||
| 88 | 91 | private final RemoteApiVersion apiVersion; | |
| 89 | 92 | ||
| 90 | - private DockerConfigFile dockerConfig = null; | ||
| 93 | + private final DockerConfigFile dockerConfig; | ||
| 91 | 94 | ||
| 92 | - DefaultDockerClientConfig(URI dockerHost, String dockerConfigPath, String apiVersion, String registryUrl, | ||
| 93 | - String registryUsername, String registryPassword, String registryEmail, SSLConfig sslConfig) { | ||
| 95 | + DefaultDockerClientConfig(URI dockerHost, DockerConfigFile dockerConfigFile, String dockerConfigPath, String apiVersion, | ||
| 96 | + String registryUrl, String registryUsername, String registryPassword, String registryEmail, | ||
| 97 | + SSLConfig sslConfig) { | ||
| 94 | 98 | this.dockerHost = checkDockerHostScheme(dockerHost); | |
| 99 | + this.dockerConfig = dockerConfigFile; | ||
| 95 | 100 | this.dockerConfigPath = dockerConfigPath; | |
| 96 | 101 | this.apiVersion = RemoteApiVersion.parseConfigWithDefault(apiVersion); | |
| 97 | 102 | this.sslConfig = sslConfig; | |
@@ -174,6 +179,13 @@ private static Properties overrideDockerPropertiesWithEnv(Properties properties, | |||
| 174 | 179 | } | |
| 175 | 180 | } | |
| 176 | 181 | ||
| 182 | + if (env.containsKey(DOCKER_CONTEXT)) { | ||
| 183 | + String value = env.get(DOCKER_CONTEXT); | ||
| 184 | + if (value != null && value.trim().length() != 0) { | ||
| 185 | + overriddenProperties.setProperty(DOCKER_CONTEXT, value); | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + | ||
| 177 | 189 | for (Map.Entry<String, String> envEntry : env.entrySet()) { | |
| 178 | 190 | String envKey = envEntry.getKey(); | |
| 179 | 191 | if (CONFIG_KEYS.contains(envKey)) { | |
@@ -258,13 +270,6 @@ public String getDockerConfigPath() { | |||
| 258 | 270 | ||
| 259 | 271 | @Nonnull | |
| 260 | 272 | public DockerConfigFile getDockerConfig() { | |
| 261 | - if (dockerConfig == null) { | ||
| 262 | - try { | ||
| 263 | - dockerConfig = DockerConfigFile.loadConfig(getObjectMapper(), getDockerConfigPath()); | ||
| 264 | - } catch (IOException e) { | ||
| 265 | - throw new DockerClientException("Failed to parse docker configuration file", e); | ||
| 266 | - } | ||
| 267 | - } | ||
| 268 | 273 | return dockerConfig; | |
| 269 | 274 | } | |
| 270 | 275 | ||
@@ -325,7 +330,7 @@ public static class Builder { | |||
| 325 | 330 | private URI dockerHost; | |
| 326 | 331 | ||
| 327 | 332 | private String apiVersion, registryUsername, registryPassword, registryEmail, registryUrl, dockerConfig, | |
| 328 | - dockerCertPath; | ||
| 333 | + dockerCertPath, dockerContext; | ||
| 329 | 334 | ||
| 330 | 335 | private Boolean dockerTlsVerify; | |
| 331 | 336 | ||
@@ -343,6 +348,7 @@ public Builder withProperties(Properties p) { | |||
| 343 | 348 | } | |
| 344 | 349 | ||
| 345 | 350 | return withDockerTlsVerify(p.getProperty(DOCKER_TLS_VERIFY)) | |
| 351 | + .withDockerContext(p.getProperty(DOCKER_CONTEXT)) | ||
| 346 | 352 | .withDockerConfig(p.getProperty(DOCKER_CONFIG)) | |
| 347 | 353 | .withDockerCertPath(p.getProperty(DOCKER_CERT_PATH)) | |
| 348 | 354 | .withApiVersion(p.getProperty(API_VERSION)) | |
@@ -401,6 +407,11 @@ public final Builder withDockerConfig(String dockerConfig) { | |||
| 401 | 407 | return this; | |
| 402 | 408 | } | |
| 403 | 409 | ||
| 410 | + public final Builder withDockerContext(String dockerContext) { | ||
| 411 | + this.dockerContext = dockerContext; | ||
| 412 | + return this; | ||
| 413 | + } | ||
| 414 | + | ||
| 404 | 415 | public final Builder withDockerTlsVerify(String dockerTlsVerify) { | |
| 405 | 416 | if (dockerTlsVerify != null) { | |
| 406 | 417 | String trimmed = dockerTlsVerify.trim(); | |
@@ -443,14 +454,33 @@ public DefaultDockerClientConfig build() { | |||
| 443 | 454 | sslConfig = customSslConfig; | |
| 444 | 455 | } | |
| 445 | 456 | ||
| 457 | + final DockerConfigFile dockerConfigFile = readDockerConfig(); | ||
| 458 | + | ||
| 459 | + final String context = (dockerContext != null) ? dockerContext : dockerConfigFile.getCurrentContext(); | ||
| 446 | 460 | URI dockerHostUri = dockerHost != null | |
| 447 | 461 | ? dockerHost | |
| 448 | - : URI.create(SystemUtils.IS_OS_WINDOWS ? WINDOWS_DEFAULT_DOCKER_HOST : DEFAULT_DOCKER_HOST); | ||
| 462 | + : resolveDockerHost(context); | ||
| 449 | 463 | ||
| 450 | - return new DefaultDockerClientConfig(dockerHostUri, dockerConfig, apiVersion, registryUrl, registryUsername, | ||
| 464 | + return new DefaultDockerClientConfig(dockerHostUri, dockerConfigFile, dockerConfig, apiVersion, registryUrl, registryUsername, | ||
| 451 | 465 | registryPassword, registryEmail, sslConfig); | |
| 452 | 466 | } | |
| 453 | 467 | ||
| 468 | + private DockerConfigFile readDockerConfig() { | ||
| 469 | + try { | ||
| 470 | + return DockerConfigFile.loadConfig(DockerClientConfig.getDefaultObjectMapper(), dockerConfig); | ||
| 471 | + } catch (IOException e) { | ||
| 472 | + throw new DockerClientException("Failed to parse docker configuration file", e); | ||
| 473 | + } | ||
| 474 | + } | ||
| 475 | + | ||
| 476 | + private URI resolveDockerHost(String dockerContext) { | ||
| 477 | + return URI.create(Optional.ofNullable(dockerContext) | ||
| 478 | + .flatMap(context -> DockerContextMetaFile.resolveContextMetaFile( | ||
| 479 | + DockerClientConfig.getDefaultObjectMapper(), new File(dockerConfig), context)) | ||
| 480 | + .flatMap(DockerContextMetaFile::host) | ||
| 481 | + .orElse(SystemUtils.IS_OS_WINDOWS ? WINDOWS_DEFAULT_DOCKER_HOST : DEFAULT_DOCKER_HOST)); | ||
| 482 | + } | ||
| 483 | + | ||
| 454 | 484 | private String checkDockerCertPath(String dockerCertPath) { | |
| 455 | 485 | if (StringUtils.isEmpty(dockerCertPath)) { | |
| 456 | 486 | throw new DockerClientException( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | import com.fasterxml.jackson.databind.ObjectMapper; | |
| 6 | 6 | import com.github.dockerjava.api.model.AuthConfig; | |
| 7 | 7 | import com.github.dockerjava.api.model.AuthConfigurations; | |
| 8 | + import java.util.Objects; | ||
| 8 | 9 | import org.apache.commons.io.FileUtils; | |
| 9 | 10 | import org.apache.commons.lang3.StringUtils; | |
| 10 | 11 | ||
@@ -29,6 +30,9 @@ public class DockerConfigFile { | |||
| 29 | 30 | @JsonProperty | |
| 30 | 31 | private final Map<String, AuthConfig> auths; | |
| 31 | 32 | ||
| 33 | + @JsonProperty | ||
| 34 | + private String currentContext; | ||
| 35 | + | ||
| 32 | 36 | public DockerConfigFile() { | |
| 33 | 37 | this(new HashMap<>()); | |
| 34 | 38 | } | |
@@ -46,6 +50,14 @@ void addAuthConfig(AuthConfig config) { | |||
| 46 | 50 | auths.put(config.getRegistryAddress(), config); | |
| 47 | 51 | } | |
| 48 | 52 | ||
| 53 | + void setCurrentContext(String currentContext) { | ||
| 54 | + this.currentContext = currentContext; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public String getCurrentContext() { | ||
| 58 | + return currentContext; | ||
| 59 | + } | ||
| 60 | + | ||
| 49 | 61 | @CheckForNull | |
| 50 | 62 | public AuthConfig resolveAuthConfig(@CheckForNull String hostname) { | |
| 51 | 63 | if (StringUtils.isEmpty(hostname) || AuthConfig.DEFAULT_SERVER_ADDRESS.equals(hostname)) { | |
@@ -104,14 +116,17 @@ public boolean equals(Object obj) { | |||
| 104 | 116 | return false; | |
| 105 | 117 | } else if (!auths.equals(other.auths)) | |
| 106 | 118 | return false; | |
| 119 | + if (!Objects.equals(currentContext, other.currentContext)) { | ||
| 120 | + return false; | ||
| 121 | + } | ||
| 107 | 122 | return true; | |
| 108 | 123 | } | |
| 109 | 124 | ||
| 110 | 125 | // CHECKSTYLE:ON | |
| 111 | 126 | ||
| 112 | 127 | @Override | |
| 113 | 128 | public String toString() { | |
| 114 | - return "DockerConfigFile [auths=" + auths + "]"; | ||
| 129 | + return "DockerConfigFile [auths=" + auths + ", currentContext='" + currentContext + "']"; | ||
| 115 | 130 | } | |
| 116 | 131 | ||
| 117 | 132 | @Nonnull | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,66 @@ | |||
| 1 | + package com.github.dockerjava.core; | ||
| 2 | + | ||
| 3 | + import com.fasterxml.jackson.annotation.JsonProperty; | ||
| 4 | + import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 5 | + import com.google.common.hash.HashFunction; | ||
| 6 | + import com.google.common.hash.Hashing; | ||
| 7 | + import java.io.File; | ||
| 8 | + import java.io.IOException; | ||
| 9 | + import java.nio.charset.StandardCharsets; | ||
| 10 | + import java.util.Optional; | ||
| 11 | + | ||
| 12 | + public class DockerContextMetaFile { | ||
| 13 | + private static HashFunction metaHashFunction = Hashing.sha256(); | ||
| 14 | + | ||
| 15 | + @JsonProperty("Name") | ||
| 16 | + String name; | ||
| 17 | + | ||
| 18 | + @JsonProperty("Endpoints") | ||
| 19 | + Endpoints endpoints; | ||
| 20 | + | ||
| 21 | + public static class Endpoints { | ||
| 22 | + @JsonProperty("docker") | ||
| 23 | + Docker docker; | ||
| 24 | + | ||
| 25 | + public static class Docker { | ||
| 26 | + @JsonProperty("Host") | ||
| 27 | + String host; | ||
| 28 | + | ||
| 29 | + @JsonProperty("SkipTLSVerify") | ||
| 30 | + boolean skipTLSVerify; | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public Optional<String> host() { | ||
| 35 | + if (endpoints != null && endpoints.docker != null) { | ||
| 36 | + return Optional.ofNullable(endpoints.docker.host); | ||
| 37 | + } | ||
| 38 | + return Optional.empty(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public static Optional<DockerContextMetaFile> resolveContextMetaFile(ObjectMapper objectMapper, File dockerConfigPath, String context) { | ||
| 42 | + final File path = dockerConfigPath.toPath() | ||
| 43 | + .resolve("contexts") | ||
| 44 | + .resolve("meta") | ||
| 45 | + .resolve(metaHashFunction.hashString(context, StandardCharsets.UTF_8).toString()) | ||
| 46 | + .resolve("meta.json") | ||
| 47 | + .toFile(); | ||
| 48 | + return Optional.ofNullable(loadContextMetaFile(objectMapper, path)); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public static DockerContextMetaFile loadContextMetaFile(ObjectMapper objectMapper, File dockerContextMetaFile) { | ||
| 52 | + try { | ||
| 53 | + return parseContextMetaFile(objectMapper, dockerContextMetaFile); | ||
| 54 | + } catch (Exception exception) { | ||
| 55 | + return null; | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public static DockerContextMetaFile parseContextMetaFile(ObjectMapper objectMapper, File dockerContextMetaFile) throws IOException { | ||
| 60 | + try { | ||
| 61 | + return objectMapper.readValue(dockerContextMetaFile, DockerContextMetaFile.class); | ||
| 62 | + } catch (IOException e) { | ||
| 63 | + throw new IOException("Failed to parse docker context meta file " + dockerContextMetaFile, e); | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,9 @@ | |||
| 1 | 1 | package com.github.dockerjava.core; | |
| 2 | 2 | ||
| 3 | - import com.github.dockerjava.api.exception.DockerClientException; | ||
| 4 | 3 | import com.github.dockerjava.api.model.AuthConfig; | |
| 5 | 4 | import com.github.dockerjava.api.model.AuthConfigurations; | |
| 6 | 5 | import com.google.common.io.Resources; | |
| 6 | + import java.io.IOException; | ||
| 7 | 7 | import org.apache.commons.lang3.SerializationUtils; | |
| 8 | 8 | import org.junit.Test; | |
| 9 | 9 | ||
@@ -27,13 +27,26 @@ | |||
| 27 | 27 | public class DefaultDockerClientConfigTest { | |
| 28 | 28 | ||
| 29 | 29 | public static final DefaultDockerClientConfig EXAMPLE_CONFIG = newExampleConfig(); | |
| 30 | + public static final DefaultDockerClientConfig EXAMPLE_CONFIG_FULLY_LOADED = newExampleConfigFullyLoaded(); | ||
| 30 | 31 | ||
| 31 | 32 | private static DefaultDockerClientConfig newExampleConfig() { | |
| 32 | - | ||
| 33 | 33 | String dockerCertPath = dockerCertPath(); | |
| 34 | + return new DefaultDockerClientConfig(URI.create("tcp://foo"), null, "dockerConfig", "apiVersion", "registryUrl", | ||
| 35 | + "registryUsername", "registryPassword", "registryEmail", | ||
| 36 | + new LocalDirectorySSLConfig(dockerCertPath)); | ||
| 37 | + } | ||
| 34 | 38 | ||
| 35 | - return new DefaultDockerClientConfig(URI.create("tcp://foo"), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | ||
| 39 | + private static DefaultDockerClientConfig newExampleConfigFullyLoaded() { | ||
| 40 | + try { | ||
| 41 | + String dockerCertPath = dockerCertPath(); | ||
| 42 | + String dockerConfig = "dockerConfig"; | ||
| 43 | + DockerConfigFile loadedConfigFile = DockerConfigFile.loadConfig(DockerClientConfig.getDefaultObjectMapper(), dockerConfig); | ||
| 44 | + return new DefaultDockerClientConfig(URI.create("tcp://foo"), loadedConfigFile, dockerConfig, "apiVersion", "registryUrl", | ||
| 45 | + "registryUsername", "registryPassword", "registryEmail", | ||
| 36 | 46 | new LocalDirectorySSLConfig(dockerCertPath)); | |
| 47 | + } catch (IOException exception) { | ||
| 48 | + throw new RuntimeException(exception); | ||
| 49 | + } | ||
| 37 | 50 | } | |
| 38 | 51 | ||
| 39 | 52 | private static String homeDir() { | |
@@ -69,6 +82,37 @@ public void environmentDockerHost() throws Exception { | |||
| 69 | 82 | assertEquals(config.getDockerHost(), URI.create("tcp://baz:8768")); | |
| 70 | 83 | } | |
| 71 | 84 | ||
| 85 | + @Test | ||
| 86 | + public void dockerContextFromConfig() throws Exception { | ||
| 87 | + // given home directory with docker contexts configured | ||
| 88 | + Properties systemProperties = new Properties(); | ||
| 89 | + systemProperties.setProperty("user.home", "target/test-classes/dockerContextHomeDir"); | ||
| 90 | + | ||
| 91 | + // and an empty environment | ||
| 92 | + Map<String, String> env = new HashMap<>(); | ||
| 93 | + | ||
| 94 | + // when you build a config | ||
| 95 | + DefaultDockerClientConfig config = buildConfig(env, systemProperties); | ||
| 96 | + | ||
| 97 | + assertEquals(URI.create("unix:///configcontext.sock"), config.getDockerHost()); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + @Test | ||
| 101 | + public void dockerContextFromEnvironmentVariable() throws Exception { | ||
| 102 | + // given home directory with docker contexts | ||
| 103 | + Properties systemProperties = new Properties(); | ||
| 104 | + systemProperties.setProperty("user.home", "target/test-classes/dockerContextHomeDir"); | ||
| 105 | + | ||
| 106 | + // and an environment variable that overrides docker context | ||
| 107 | + Map<String, String> env = new HashMap<>(); | ||
| 108 | + env.put(DefaultDockerClientConfig.DOCKER_CONTEXT, "envvarcontext"); | ||
| 109 | + | ||
| 110 | + // when you build a config | ||
| 111 | + DefaultDockerClientConfig config = buildConfig(env, systemProperties); | ||
| 112 | + | ||
| 113 | + assertEquals(URI.create("unix:///envvarcontext.sock"), config.getDockerHost()); | ||
| 114 | + } | ||
| 115 | + | ||
| 72 | 116 | @Test | |
| 73 | 117 | public void environment() throws Exception { | |
| 74 | 118 | ||
@@ -88,7 +132,7 @@ public void environment() throws Exception { | |||
| 88 | 132 | DefaultDockerClientConfig config = buildConfig(env, new Properties()); | |
| 89 | 133 | ||
| 90 | 134 | // then we get the example object | |
| 91 | - assertEquals(config, EXAMPLE_CONFIG); | ||
| 135 | + assertEquals(EXAMPLE_CONFIG_FULLY_LOADED, config); | ||
| 92 | 136 | } | |
| 93 | 137 | ||
| 94 | 138 | @Test | |
@@ -147,7 +191,7 @@ public void systemProperties() throws Exception { | |||
| 147 | 191 | DefaultDockerClientConfig config = buildConfig(Collections.<String, String> emptyMap(), systemProperties); | |
| 148 | 192 | ||
| 149 | 193 | // then it is the same as the example | |
| 150 | - assertEquals(config, EXAMPLE_CONFIG); | ||
| 194 | + assertEquals(EXAMPLE_CONFIG_FULLY_LOADED, config); | ||
| 151 | 195 | ||
| 152 | 196 | } | |
| 153 | 197 | ||
@@ -161,22 +205,22 @@ public void serializableTest() { | |||
| 161 | 205 | ||
| 162 | 206 | @Test() | |
| 163 | 207 | public void testSslContextEmpty() throws Exception { | |
| 164 | - new DefaultDockerClientConfig(URI.create("tcp://foo"), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | ||
| 208 | + new DefaultDockerClientConfig(URI.create("tcp://foo"), new DockerConfigFile(), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | ||
| 165 | 209 | null); | |
| 166 | 210 | } | |
| 167 | 211 | ||
| 168 | 212 | ||
| 169 | 213 | ||
| 170 | 214 | @Test() | |
| 171 | 215 | public void testTlsVerifyAndCertPath() throws Exception { | |
| 172 | - new DefaultDockerClientConfig(URI.create("tcp://foo"), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | ||
| 216 | + new DefaultDockerClientConfig(URI.create("tcp://foo"), new DockerConfigFile(), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | ||
| 173 | 217 | new LocalDirectorySSLConfig(dockerCertPath())); | |
| 174 | 218 | } | |
| 175 | 219 | ||
| 176 | 220 | @Test() | |
| 177 | 221 | public void testAnyHostScheme() throws Exception { | |
| 178 | 222 | URI dockerHost = URI.create("a" + UUID.randomUUID().toString().replace("-", "") + "://foo"); | |
| 179 | - new DefaultDockerClientConfig(dockerHost, "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | ||
| 223 | + new DefaultDockerClientConfig(dockerHost, new DockerConfigFile(), "dockerConfig", "apiVersion", "registryUrl", "registryUsername", "registryPassword", "registryEmail", | ||
| 180 | 224 | null); | |
| 181 | 225 | } | |
| 182 | 226 | ||
@@ -249,10 +293,12 @@ public void dockerHostSetExplicitlyIfSetToDefaultByUser() { | |||
| 249 | 293 | ||
| 250 | 294 | ||
| 251 | 295 | @Test | |
| 252 | - public void testGetAuthConfigurationsFromDockerCfg() throws URISyntaxException { | ||
| 296 | + public void testGetAuthConfigurationsFromDockerCfg() throws URISyntaxException, IOException { | ||
| 253 | 297 | File cfgFile = new File(Resources.getResource("com.github.dockerjava.core/registry.v1").toURI()); | |
| 298 | + DockerConfigFile dockerConfigFile = | ||
| 299 | + DockerConfigFile.loadConfig(DockerClientConfig.getDefaultObjectMapper(), cfgFile.getAbsolutePath()); | ||
| 254 | 300 | DefaultDockerClientConfig clientConfig = new DefaultDockerClientConfig(URI.create( | |
| 255 | - "unix://foo"), cfgFile.getAbsolutePath(), "apiVersion", "registryUrl", "registryUsername", "registryPassword", | ||
| 301 | + "unix://foo"), dockerConfigFile, cfgFile.getAbsolutePath(), "apiVersion", "registryUrl", "registryUsername", "registryPassword", | ||
| 256 | 302 | "registryEmail", null); | |
| 257 | 303 | ||
| 258 | 304 | AuthConfigurations authConfigurations = clientConfig.getAuthConfigurations(); | |
@@ -265,10 +311,12 @@ public void testGetAuthConfigurationsFromDockerCfg() throws URISyntaxException { | |||
| 265 | 311 | } | |
| 266 | 312 | ||
| 267 | 313 | @Test | |
| 268 | - public void testGetAuthConfigurationsFromConfigJson() throws URISyntaxException { | ||
| 314 | + public void testGetAuthConfigurationsFromConfigJson() throws URISyntaxException, IOException { | ||
| 269 | 315 | File cfgFile = new File(Resources.getResource("com.github.dockerjava.core/registry.v2").toURI()); | |
| 316 | + DockerConfigFile dockerConfigFile = | ||
| 317 | + DockerConfigFile.loadConfig(DockerClientConfig.getDefaultObjectMapper(), cfgFile.getAbsolutePath()); | ||
| 270 | 318 | DefaultDockerClientConfig clientConfig = new DefaultDockerClientConfig(URI.create( | |
| 271 | - "unix://foo"), cfgFile.getAbsolutePath(), "apiVersion", "registryUrl", "registryUsername", "registryPassword", | ||
| 319 | + "unix://foo"), dockerConfigFile, cfgFile.getAbsolutePath(), "apiVersion", "registryUrl", "registryUsername", "registryPassword", | ||
| 272 | 320 | "registryEmail", null); | |
| 273 | 321 | ||
| 274 | 322 | AuthConfigurations authConfigurations = clientConfig.getAuthConfigurations(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments