X Tutup
Skip to content
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
@@ -1,6 +1,7 @@
package com.github.dockerjava.core;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dockerjava.api.model.AuthConfig;
Expand Down Expand Up @@ -28,7 +29,7 @@ public class DockerConfigFile {
};

@JsonProperty
private final Map<String, AuthConfig> auths;
private Map<String, AuthConfig> auths;

@JsonProperty
private String currentContext;
Expand All @@ -46,6 +47,11 @@ public Map<String, AuthConfig> getAuths() {
return auths;
}

@JsonSetter
public void setAuths(Map<String, AuthConfig> authConfigMap) {
auths = (authConfigMap == null || authConfigMap.size() == 0) ? new HashMap<>() : authConfigMap;
}

void addAuthConfig(AuthConfig config) {
auths.put(config.getRegistryAddress(), config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ public void nonExistent() throws IOException {
assertThat(runTest("idontexist"), is(expected));
}

@Test
public void validJsonAuthsNull() throws IOException {
DockerConfigFile expected = new DockerConfigFile();
assertThat(runTest("validJsonAuthsNull"), is(expected));
}

private DockerConfigFile runTest(String testFileName) throws IOException {
return DockerConfigFile.loadConfig(JSONTestHelper.getMapper(), new File(FILESROOT, testFileName).getAbsolutePath());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"auths": null,
"credsStore": "desktop",
"plugins": {
"-x-cli-hints": {
"enabled": "true"
}
}
}
X Tutup