Skip to content

Conversation

@wking
Copy link
Contributor

@wking wking commented Sep 23, 2017

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.

If the ref-engine we're checking returns no results, keep going (even
if it didn't return an error).  Also document the "ref-engine knows it
doesn't have that name" results in the Engine.Get interface.
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 bytes that
I use in resolvedName.MarshalJSON.  Washing through bytes 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 bb96e49
(tools/refenginediscovery: Refactor Ref-Engine Discovery library API,
2017-09-20, xiekeyang#29), since that's when we started using a
map[string]interface{} in MerkleRoot.MarshalJSON.
@wking wking force-pushed the go-expose-ref-engine-discovery-casEngines branch from 585f61f to c0c2e99 Compare September 23, 2017 05:04
@xiekeyang
Copy link
Owner

LGTM

@xiekeyang xiekeyang merged commit 6b7b795 into xiekeyang:master Sep 23, 2017
@wking wking deleted the go-expose-ref-engine-discovery-casEngines branch September 25, 2017 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants