Skip to content

Commit bf805cd

Browse files
authored
Fix registry credential retrieval order (GoogleContainerTools#402)
1 parent 390e2ed commit bf805cd

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/RetrieveRegistryCredentialsStep.java‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,6 @@ public Authorization call() throws IOException, NonexistentDockerCredentialHelpe
138138
return knownRegistryCredentials.getAuthorization();
139139
}
140140

141-
// Tries to get registry credentials from the Docker config.
142-
try {
143-
Authorization dockerConfigAuthorization = dockerConfigCredentialRetriever.retrieve();
144-
if (dockerConfigAuthorization != null) {
145-
buildLogger.info("Using credentials from Docker config for " + registry);
146-
return dockerConfigAuthorization;
147-
}
148-
149-
} catch (IOException ex) {
150-
buildLogger.info("Unable to parse Docker config");
151-
}
152-
153141
// Tries to infer common credential helpers for known registries.
154142
for (String registrySuffix : COMMON_CREDENTIAL_HELPERS.keySet()) {
155143
if (registry.endsWith(registrySuffix)) {
@@ -173,6 +161,18 @@ public Authorization call() throws IOException, NonexistentDockerCredentialHelpe
173161
}
174162
}
175163

164+
// Tries to get registry credentials from the Docker config.
165+
try {
166+
Authorization dockerConfigAuthorization = dockerConfigCredentialRetriever.retrieve();
167+
if (dockerConfigAuthorization != null) {
168+
buildLogger.info("Using credentials from Docker config for " + registry);
169+
return dockerConfigAuthorization;
170+
}
171+
172+
} catch (IOException ex) {
173+
buildLogger.info("Unable to parse Docker config");
174+
}
175+
176176
/*
177177
* If no credentials found, give an info (not warning because in most cases, the base image is
178178
* public and does not need extra credentials) and return null.

0 commit comments

Comments
 (0)