Skip to content

Commit

Permalink
Don't use image username for auto pull
Browse files Browse the repository at this point in the history
If a default login for the registry is configured for authentication this will be used, regardless of the image's username. If no default login is registered, no authentication is used.

This affects only pulling. For push, the default user is extracted from the image name (but can be overwritten with options and config).

This also will fix fabric8io/fabric8-devops#46

Relates to #147
  • Loading branch information
rhuss committed Oct 6, 2015
1 parent e048821 commit 939d32f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ChangeLog

* **0.13.6-SNAPSHOT**
- Don't use user from image when pulling base images (#147)

* **0.13.5**
- Improvements for `docker:watch` ([#288](https://github.com/rhuss/docker-maven-plugin/issues/288))
- Add parameter `kill` to `<watch>` configuration for waiting before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ public void contextualize(Context context) throws ContextException {

// =================================================================================

protected AuthConfig prepareAuthConfig(String image, String configuredRegistry) throws MojoExecutionException {
protected AuthConfig prepareAuthConfig(String image, String configuredRegistry, boolean useUserFromImage) throws MojoExecutionException {
ImageName name = new ImageName(image);
String user = name.getUser();
String user = useUserFromImage ? name.getUser() : null;
String registry = name.getRegistry() != null ? name.getRegistry() : configuredRegistry;

return authConfigFactory.createAuthConfig(authConfig, settings, user, registry);
Expand Down Expand Up @@ -323,7 +323,7 @@ protected void checkImageWithAutoPull(DockerAccess docker, String image, String
return;
}

docker.pullImage(withLatestIfNoTag(image), prepareAuthConfig(image, registry), registry);
docker.pullImage(withLatestIfNoTag(image), prepareAuthConfig(image, registry, false), registry);
ImageName imageName = new ImageName(image);
if (registry != null && !imageName.hasRegistry()) {
// If coming from a registry which was not contained in the original name, add a tag from the
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jolokia/docker/maven/PushMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void executeInternal(DockerAccess docker) throws DockerAccessException, M
String name = imageConfig.getName();
if (buildConfig != null) {
String configuredRegistry = getConfiguredRegistry(imageConfig);
AuthConfig authConfig = prepareAuthConfig(name,configuredRegistry);
AuthConfig authConfig = prepareAuthConfig(name, configuredRegistry, true);

docker.pushImage(name, authConfig, configuredRegistry);

Expand Down

0 comments on commit 939d32f

Please sign in to comment.