-
Notifications
You must be signed in to change notification settings - Fork 242
Import path should be opaque #190
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
Comments
You're right. Thanks for pointing this out. This was done for compatibility with C++ jsonnet. IMO the right way to do it would be to have @sparkprime What do you think? |
Yes I was thinking the same. I also think that was proposed in google/jsonnet#239 |
In other words, if the importer is responsible for deriving the new path from the current file and the possibly relative import string, then there is no need for it to expose a splitting function. |
Just to provide some context, I stumbled upon this when implementing an importer that would support URLs in |
C++ implementation did not canonicalize paths: https://github.com/google/jsonnet/blob/master/core/vm.cpp#L37 |
As discussed in google#190
As discussed in google#190
As discussed in google#190
As discussed in google#190
This has been solved a while back. |
Uh oh!
There was an error while loading. Please reload this page.
When importing jsonnet documents using the
import
statement, the current implementation assumes that the resource returned from importer'sFoundHere
is a filesystem path. On subsequent imports, the base dir of that path is derived via a call topath.Dir()
(see e.g. https://github.com/google/go-jsonnet/blob/master/interpreter.go#L415). This function always performs a path cleanup.This is a problem when implementing custom importers that do not use filesystem paths, but for example URLs. E.g. when an importer returns
https://github.com/raw/ksonnet/ksonnet-lib/master/ksonnet.beta.2/k.libsonnet
inFoundHere
, upon resolving relative imports based on that URL, theimportDir
comes back to the importer cleaned up ashttps:/raw.githubusercontent.com/ksonnet/ksonnet-lib/master/ksonnet.beta.2
(notice the single forward slash inhttps:/
).go-jsonnet
should not assume filesystem paths, in fact the resource "path" should be opaque.The text was updated successfully, but these errors were encountered: