change auth config ordering
@@ -63,20 +63,20 @@ class RegistryAuthLocator {
* Gets authorization information
* using $DOCKER_CONFIG/.docker/config.json file
* If missing, returns empty AuthConfig object
- * @param registryCredentials extension of type registryCredentials
* @param image the name of docker image the action to be authorized for
* @return AuthConfig object with a credentials info or empty object if
* no credentials found
*/
AuthConfig lookupAuthConfig(String image) {
- return lookupAuthConfig(image, new AuthConfig())
+ AuthConfig authConfigForRepository = lookupAuthConfigForRegistry(getRegistry(image))
+ return authConfigForRepository ?: new AuthConfig()
}
/**
* Gets authorization information
- * using $DOCKER_CONFIG/.docker/config.json file
+ * using the registryCredentials object
* If missing, gets the information from
- * the registryCredentials object
+ * $DOCKER_CONFIG/.docker/config.json file
* @param registryCredentials extension of type registryCredentials
* @param image the name of docker image the action to be authorized for
* @return AuthConfig object with a credentials info or default object if
@@ -84,22 +84,12 @@ class RegistryAuthLocator {
*/
AuthConfig lookupAuthConfig(String image,
DockerRegistryCredentials registryCredentials) {
- AuthConfig defaultConfig = createAuthConfig(registryCredentials)
- return lookupAuthConfig(image, defaultConfig)
- }
-
- /**
- * Gets authorization information using $DOCKER_CONFIG/.docker/config.json file
- * @param image the name of docker image the action to be authorized for
- * @return AuthConfig object with a credentials info or default object if
- * no credentials found
- */
- AuthConfig lookupAuthConfig(String image, AuthConfig defaultAuthConfig) {
- AuthConfig authConfigForRegistry = lookupAuthConfigForRegistry(getRegistry(image))
- if (authConfigForRegistry != null) {
- return authConfigForRegistry
+ String registry = getRegistry(image)
+ String registryUrl = registryCredentials.getUrl().getOrElse("")
+ if (registryUrl.endsWith('://' + registry) || registryUrl == registry) {
+ return createAuthConfig(registryCredentials)
}
- return defaultAuthConfig
+ return lookupAuthConfig(image)
}
private AuthConfig lookupAuthConfigForRegistry(String registry) {
