Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add setter to auths if it's null to avoid NPE when getting auths #2142

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

Merged
merged 1 commit into from
Jul 30, 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
@@ -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"
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.