Previously these were not provided in the output JSON.
To store the data during resolution, create a new resolvedName type. That type extends the usual MerkleRoot JSON with a new casEngines property that is a sibling of MerkleRoot's root and uri properties. To get the sibling serialization, we need a little MarshalJSON wrapper for resolvedName, but we don't need to bother with UnmarshalJSON because this isn't a public library type.
Rename allRoots to resolvedNames, because each key in the map is an image name. Each value in the map may contain several roots (resolveNames), so allRoots wasn't particularly clear.
Move refenginediscovery.ResolvedCASEngine to engine.Reference. This gives us a shorter name, and lets us recycle some code via the new (private) (*Config).unmarshalInterface. That lets us get the same config serialization in Reference without the wash through []byte that I use in resolvedName.MarshalJSON. Washing through []byte is an acceptable hack for command-line-specific code, but it's nice to avoid it in the library code.
While we're at it, clean up the MerkleRoot JSON handling, dropping the tag from MediaType (redundant because our JSON helpers don't use reflection) and adding comments for the public methods.
Alphabetizing the root entries in the oci-discovery README example probably should have happened back in #29, since that's when we started using a map[string]interface{} in MerkleRoot.MarshalJSON.
Previously these were not provided in the output JSON.
To store the data during resolution, create a new
resolvedName
type. That type extends the usualMerkleRoot
JSON with a newcasEngines
property that is a sibling ofMerkleRoot
'sroot
anduri
properties. To get the sibling serialization, we need a littleMarshalJSON
wrapper forresolvedName
, but we don't need to bother withUnmarshalJSON
because this isn't a public library type.Rename
allRoots
toresolvedNames
, because each key in the map is an image name. Each value in the map may contain several roots (resolveName
s), soallRoots
wasn't particularly clear.Move
refenginediscovery.ResolvedCASEngine
toengine.Reference
. This gives us a shorter name, and lets us recycle some code via the new (private)(*Config).unmarshalInterface
. That lets us get the same config serialization inReference
without the wash through[]byte
that I use inresolvedName.MarshalJSON
. Washing through[]byte
is an acceptable hack for command-line-specific code, but it's nice to avoid it in the library code.While we're at it, clean up the
MerkleRoot
JSON handling, dropping the tag fromMediaType
(redundant because our JSON helpers don't use reflection) and adding comments for the public methods.Alphabetizing the root entries in the oci-discovery README example probably should have happened back in #29, since that's when we started using a
map[string]interface{}
inMerkleRoot.MarshalJSON
.Builds on #38; review that first.