xiekeyang / oci-discovery

Contain the OCI Ref-engine Discovery specification and related specifications as an extention to the image specification.
Other
2 stars 1 forks source link

tools: Expose ref-engine discovery casEngines #39

Closed wking closed 7 years ago

wking commented 7 years ago

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.

Builds on #38; review that first.

xiekeyang commented 7 years ago

LGTM