Skip to content

Commit

Permalink
fix(auth): Non existing version command on credential helper is ignor…
Browse files Browse the repository at this point in the history
…ed (#1190)

Fixes #1159.
  • Loading branch information
rhuss authored Apr 6, 2019
1 parent b414b9b commit dc82c82
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
3 changes: 2 additions & 1 deletion doc/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ChangeLog

* 0.28.1
* **0.28-SNAPSHOT**
- Reintroduce minimal API-VERSION parameter in order to support docker versions below apiVersion 1.25
- docs: Correct default image naming
- Proxy settings are being ignored ([#1148](https://github.com/fabric8io/docker-maven-plugin/issues/1148))
Expand All @@ -13,6 +13,7 @@
- Added 'autoRemove' option for running containers (#1179)
- Added support for AWS EC2 instance roles when pushing to AWS ECR (#1186)
- Add support for auto-pulling multiple base image for multi stage builds (#1057)
- Fix usage of credential helper that do not support 'version' command (#1159)

* **0.28.0** (2018-12-13)
- Update to JMockit 1.43
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private AuthConfig createStandardAuthConfig(boolean isPush, Map authConfigMap, S
log.debug("AuthConfig: credentials from ~/.m2/setting.xml");
return ret;
}

// check EC2 instance role if registry is ECR
if (EcrExtendedAuth.isAwsRegistry(registry)) {
try {
Expand All @@ -253,8 +253,8 @@ private AuthConfig createStandardAuthConfig(boolean isPush, Map authConfigMap, S
}

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


// if the local credentials don't contain user and password, use EC2 instance
// role credentials
private AuthConfig getAuthConfigFromEC2InstanceRole() throws IOException {
Expand Down Expand Up @@ -310,7 +310,7 @@ private AuthConfig getAuthConfigFromEC2InstanceRole() throws IOException {
}
}
}

private AuthConfig getAuthConfigFromSystemProperties(LookupMode lookupMode) throws MojoExecutionException {
Properties props = System.getProperties();
String userKey = lookupMode.asSysProperty(AUTH_USERNAME);
Expand Down Expand Up @@ -423,9 +423,10 @@ private AuthConfig extractAuthConfigFromAuths(String registryToLookup, JsonObjec

private AuthConfig extractAuthConfigFromCredentialsHelper(String registryToLookup, String credConfig) throws MojoExecutionException {
CredentialHelperClient credentialHelper = new CredentialHelperClient(log, credConfig);
log.debug("AuthConfig: credentials from credential helper/store %s version %s",
String version = credentialHelper.getVersion();
log.debug("AuthConfig: credentials from credential helper/store %s%s",
credentialHelper.getName(),
credentialHelper.getVersion());
version != null ? " version " + version : "");
return credentialHelper.getAuthConfig(registryToLookup);
}

Expand Down Expand Up @@ -523,7 +524,7 @@ private AuthConfig validateMandatoryOpenShiftLogin(AuthConfig openShiftAuthConfi
useOpenAuthModeProp, kubeConfigEnv != null ? kubeConfigEnv : "~/.kube/config"));

}


private Server checkForServer(Server server, String id, String registry, String user) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public String getName() {
return credentialHelperName;
}

public String getVersion() throws MojoExecutionException {
public String getVersion() {
try {
return new VersionCommand().getVersion();
} catch (IOException e) {
throw new MojoExecutionException("Error getting the version of the configured credential helper",e);
return null;
}
}

Expand Down Expand Up @@ -79,9 +79,6 @@ protected void processLine(String line) {

public String getVersion() throws IOException {
execute();
if (version == null) {
log.verbose("The credentials helper \"%s\" didn't return a version string",CredentialHelperClient.this.credentialHelperName);
}
return version;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void exec(File homeDir) throws IOException, MojoExecutionException {
expectedException.expect(MojoExecutionException.class);
expectedException.expectCause(Matchers.<Throwable>allOf(
instanceOf(IOException.class),
hasProperty("message",startsWith("Failed to start 'docker-credential-credHelper1-does-not-exist version'"))
hasProperty("message",startsWith("Failed to start 'docker-credential-credHelper1-does-not-exist get'"))
));
factory.createAuthConfig(isPush,false,null,settings,"roland","registry1");
}
Expand All @@ -185,7 +185,7 @@ public void exec(File homeDir) throws IOException, MojoExecutionException {
expectedException.expect(MojoExecutionException.class);
expectedException.expectCause(Matchers.<Throwable>allOf(
instanceOf(IOException.class),
hasProperty("message",startsWith("Failed to start 'docker-credential-credsStore-does-not-exist version'"))
hasProperty("message",startsWith("Failed to start 'docker-credential-credsStore-does-not-exist get'"))
));
factory.createAuthConfig(isPush,false,null,settings,"roland",null);
}
Expand All @@ -201,7 +201,7 @@ public void exec(File homeDir) throws IOException, MojoExecutionException {
expectedException.expect(MojoExecutionException.class);
expectedException.expectCause(Matchers.<Throwable>allOf(
instanceOf(IOException.class),
hasProperty("message",startsWith("Failed to start 'docker-credential-credsStore-does-not-exist version'"))
hasProperty("message",startsWith("Failed to start 'docker-credential-credsStore-does-not-exist get'"))
));
factory.createAuthConfig(isPush,false,null,settings,"roland","registry2");
}
Expand Down

0 comments on commit dc82c82

Please sign in to comment.