Skip to content

*-template: Cover relative references#21

Merged
xiekeyang merged 1 commit intoxiekeyang:masterfrom
wking:relative-reference-URIs
Sep 19, 2017
Merged

*-template: Cover relative references#21
xiekeyang merged 1 commit intoxiekeyang:masterfrom
wking:relative-reference-URIs

Conversation

@wking
Copy link
Copy Markdown
Contributor

@wking wking commented Sep 18, 2017

As discussed here and here. This allows for entries that can move with the base content. For example, you could have a ref-engines object at file:///srv/app/ref-engines.json with content like:

{
  "refEngines": [
    {
      "protocol": "oci-index-template-v1",
      "uri": "index.json"
    }
  ],
  "casEngines": [
    {
      "protocol": "oci-cas-template-v1",
      "uri": "blobs/{algorithm}/{encoded}"
    }
  ]
}

that now expands to file:///srv/app/index.json, file:///srv/app/blobs/sha256/e97…, etc. And those references would still expand correctly if you moved the whole /srv/app directory to /srv/new-app and referenced the ref-engines object from file:///srv/new-app/ref-engines.json.

As discussed in [1,2].  This allows for entries that can move with the
base content.  For example, you could have a ref-engines object at
file:///srv/app/ref-engines.json with content like:

  {
    "refEngines": [
      {
        "protocol": "oci-index-template-v1",
        "uri": "index.json"
      }
    ],
    "casEngines": [
      {
        "protocol": "oci-cas-template-v1",
        "uri": "blobs/{algorithm}/{encoded}"
      }
    ]
  }

that now expands to file:///srv/app/index.json,
file:///srv/app/blobs/sha256/e97..., etc.  And those references would
still expand correctly if you moved the whole /srv/app directory to
/srv/new-app and referenced the ref-engines object from
file:///srv/new-app/ref-engines.json.

[1]: https://tools.ietf.org/html/rfc3986#section-4.2
[2]: https://tools.ietf.org/html/rfc3986#section-5
@wking
Copy link
Copy Markdown
Contributor Author

wking commented Sep 18, 2017

The Go implementation of RFC 3986's relative resolution is ResolveReference.

@xiekeyang
Copy link
Copy Markdown
Owner

LGTM

@xiekeyang xiekeyang merged commit 040c873 into xiekeyang:master Sep 19, 2017
@wking wking deleted the relative-reference-URIs branch September 19, 2017 04:06
wking added a commit to wking/oci-discovery that referenced this pull request Sep 20, 2017
From [1]:

  Note that if the retrieval was the result of a redirected request,
  the last URI used (i.e., the URI that resulted in the actual
  retrieval of the representation) is the base URI.

This fills in remaining Python functionality left off from 5b75a01
(*-template: Cover relative references, 2017-09-18, xiekeyang#21).  Ref-engine
discovery and ref-engine APIs now also return dicts that include a
'uri' key representing this URI, which allows their consumers to also
perform reference resolution.  For example, tools consuming the Merkle
roots may need the URI from which those roots were extracted in order
to resolve a CAS-engine URI reference.

[1]: https://tools.ietf.org/html/rfc3986#section-5.1.3
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