-
Notifications
You must be signed in to change notification settings - Fork 1
[Splited commit]: tools/refenginediscovery: Refactor Ref-Engine Discovery library API #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pull the UI portions of this out into tools/cmd, because the library
API should not depend on urfave/cli.
The new refenginediscovery API is based on a per-configured-ref-engine
callback, which gives callers lots of flexibility in how they want to
handle each ref-engine and if/when they want to abort the
protocol/host iteration.
I've also adjusted the ref-engine interface to return a new MerkleRoot
type. This improves on the old Descriptor returns by:
* Being less opinionated about the root object, to stay in keeping
with ref-engine-discovery.md's:
The Merkle root may be a descriptor (media type
application/vnd.oci.descriptor.v1+json), or it may have a
different media type.
* Including the retrieval URI, which may be needed to expand
references in the root object (e.g. if the root has a casEngines
configuration which includes a relative reference).
These changes bring the API and output of the 'oci-discovery resolve
...' command much closer to the current Python module. The remaining
differences are the presence of a 'roots' indirection in the Python
output (currently used to pass through ref-engines-object-level
casEngines entries) and the lack of 'uri' entries for each root (which
I'm planning on adding).
Signed-off-by: xiekeyang <[email protected]>
Signed-off-by: xiekeyang <[email protected]>
| label: "manifests is not a JSON array", | ||
| response: `{"manifests": {}}`, | ||
| expected: "json: cannot unmarshal object into Go value of type []v1.Descriptor", | ||
| expected: "json: cannot unmarshal object into Go struct field Index.manifests of type []v1.Descriptor", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are due to changing versions (I developed the tests with Go 1.7.4). We probably want to use regexps instead of fixed strings. I'll put that into a rerolled #29.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to use regexps instead of fixed strings.
Done.
| } | ||
|
|
||
| uri, err := url.Parse("https://example.com/.well-known/oci-host-ref-engines") | ||
| uri, err := url.Parse("https://" + host + "/.well-known/oci-host-ref-engines") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous approach avoided this unnecessary string concatenation. And once we add DNS-ancestor walking, we'll be setting uri.Host anyway.
| response := &http.Response{ | ||
| Request: request, | ||
| Body: ioutil.NopCloser(bytes.NewReader(bodyBytes)), | ||
| Body: ioutil.NopCloser(bytes.NewReader(bodyBytes)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the sloppy commit. I've run go fmt … and squashed the fixes in here.
| } | ||
|
|
||
| assert.Equal(t, err.Error(), testcase.expected) | ||
| assert.Equal(t, testcase.expected, err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Addressed this and other instances here.
|
Closed by #29 |
split commit from #29.