Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Credentials provided by extension need to override credentials in store #1196

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public AuthConfigurations lookupAllAuthConfigs(DockerRegistryCredentials registr
*/
public AuthConfigurations lookupAllAuthConfigs(AuthConfig additionalAuthConfig) {
AuthConfigurations allAuthConfigs = lookupAllAuthConfigs();
if (allAuthConfigs.getConfigs().isEmpty()) {
if (isProvidedByBuild(additionalAuthConfig)) {
allAuthConfigs.addConfig(additionalAuthConfig);
}
return allAuthConfigs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class RegistryAuthLocatorTest extends Specification {
}

@Issue('https://github.com/bmuschko/gradle-docker-plugin/issues/985')
def "AuthLocator returns auth from file over default"() {
def "AuthLocator returns empty auth from file over default"() {
given:
RegistryAuthLocator locator =
createAuthLocatorForExistingConfigFile('config-docker-hub-user-pass.json', false)
Expand All @@ -154,6 +154,33 @@ class RegistryAuthLocatorTest extends Specification {
0 * logger.error(*_)
}

@Issue('https://github.com/bmuschko/gradle-docker-plugin/issues/1179')
def "AuthLocator returns valid auth from file and default"() {
given:
RegistryAuthLocator locator =
createAuthLocatorForExistingConfigFile('config-docker-hub-user-pass.json', false)

when:
AuthConfigurations allConfigs = locator.lookupAllAuthConfigs(new AuthConfig()
.withRegistryAddress("https://index.docker.io/v2/")
.withUsername("username2")
.withPassword("secret2"))

then:
AuthConfig config = new AuthConfig()
.withUsername('username')
.withPassword('secret')
AuthConfig configAddon = new AuthConfig()
.withRegistryAddress("https://index.docker.io/v2/")
.withUsername('username2')
.withPassword('secret2')
allConfigs.configs.size() == 2
allConfigs.configs.get(config.registryAddress) == config
allConfigs.configs.get(configAddon.registryAddress) == configAddon

0 * logger.error(*_)
}

def "AuthLocator returns correct default registry"() {
given:
String image = 'ubuntu'
Expand Down
Loading