Don't loose additional metadata fields when read/writing contexts metadata #2572
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
- What I did
Make the cli accept additional (untyped) fields in its contexts metadata. Primary goal is to unlock interoperability with our Docker experience for Azure ACI work, which needs to add some metadata into docker contexts to work properly.
The fact that additional fields where not supported previously is actually a bug I introduced when introducing "typed endpoints and contexts metadata".
- How I did it
DockerContext struct now has a custom implementation of json.Marshaler and json.Unmarshaler, keeping addition fields in a map.
- How to verify it
docker context create test --from=default
~/.docker/contexts/meta/9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08/meta.json
) to add fields in the "metadata" object such as{"Name":"test","Metadata":{"StackOrchestrator":"swarm","AdditionalKey":"Value"},"Endpoints":{"docker":{"Host":"unix:///var/run/docker.sock","SkipTLSVerify":false}}}
docker context inspect test
with the modification should have the AdditionalKey field in its output.docker context update test --description=foo
should not drop the AdditionalKey field anymore.- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)