Skip to content
This repository has been archived by the owner on Nov 6, 2018. It is now read-only.

Docker config file with any extra properties cannot be read #106

Open
ljnelson opened this issue Feb 27, 2018 · 1 comment
Open

Docker config file with any extra properties cannot be read #106

ljnelson opened this issue Feb 27, 2018 · 1 comment

Comments

@ljnelson
Copy link

My ~/.docker/config file can't be read by the docker-client project because of overly strict JSON mapping. I receive the following error:

SEVERE: Could not load docker config file from /Users/ljnelson/.docker/config.json
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "HttpHeaders" (class io.fabric8.docker.api.model.DockerConfig), not marked as ignorable (one known property: "auths"])
     at [Source: /Users/ljnelson/.docker/config.json; line: 25, column: 20] (through reference chain: io.fabric8.docker.api.model.DockerConfig["HttpHeaders"])

This is because my (perfectly valid) ~/.docker/config file contains (among other valid things):

"HttpHeaders" : {
  "User-Agent" : "Docker-Client/17.09.0-ce (darwin)"
},
"credsStore" : "osxkeychain"

Leaving aside code generation, building, etc. if the DockerConfig.java file were edited in such a way to include @JsonIgnoreProperties(ignoreUnknown = true) that would be a quick fix.

@ljnelson
Copy link
Author

ljnelson commented Feb 27, 2018

The following hack invoked from, say, a static initializer works around the problem:

private static final void hack() throws ReflectiveOperationException {
    final Field jsonMapperField = Config.class.getDeclaredField("JSON_MAPPER");
    assert jsonMapperField != null;
    jsonMapperField.setAccessible(true);
    final ObjectMapper objectMapper = (ObjectMapper)jsonMapperField.get(null);
    assert objectMapper != null;
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant