-
Notifications
You must be signed in to change notification settings - Fork 171
Modules and imports in the Overlay, also all inputs from overlay #607
Comments
I'm not entirely sure I understand what you're asking. But It would be useful to use embedding and fs. But we aim to support at least 2 versions back, so that will take a while. Either way, these are implementation details, and overlays should work for all files. It could be that it requires a directory that is overlayed to exist, but also that could be tweaked. I'm not sure what you desired or expected here, so I can't tell what is wrong easily. |
I'm seeing issues with the overlay, I think because of the I've added some printing, working on a test file and setup, will push something to gerrit later
I've tried various settings for |
I think I found the issue:
Now, since almost all ...unless the users should be placing
But, given the comment here: https://github.com/cuelang/cue/blob/master/cue/load/config.go#L263 config settings
|
Using Overlay with 1.16's FS to embed my packages in my binary and ran into this. Also notice that there are a few filesystem requests when loading packages even if they're in
This breaks a very specific flow: I'm compiling a cue validation binary to WASM, with all cue files in memory via Overaly. However, because import.go always accesses the disk modules break and cannot be used in a webassembly build. |
`fileSystem.readDir` always reads from the actual filesystem, even if there is an overaly directory present. Read from the overlay directory in these circumstances; we shouldn't be hitting the disk. Also, if the root path is "/" we can skip loading and return true. This allows fully in-memory packages as per cuelang#607.
There are other places where Cue uses the local FS. In particular, this was a recent bugfix: a616925 Cue has a WASM playground, maybe that could help as a reference. The repo for that part is here: https://github.com/cue-sh/playground |
Yes, but in particular using overlay in a wasm environment causes an an error here: https://github.com/cuelang/cue/pull/786/files#diff-67213f39b84a013e7db04664cd3ad943b7a237d97b9c6e862d10806ac27def28R418-R420 :) There are several places where a filesystem is still expected even after that bugfix. The PR above fixes the ones that I've ran into in the latest beta. It (should) also enable module imports from overlays by fixing areas of the filesystem code that didn't inspect overlays as it probably should. |
Building on my comment in #786 (comment), like @mpvl I'm neither entirely clear what's being asked for, nor do I understand what bug is being reported in this issue. That said, thanks @verdverm and @tonyhb for looking into this, because I think there is a gap here that is nicely filled by The docs for
(I've just mailed https://cue-review.googlesource.com/c/cue/+/9021 to remove that last out-of-date paragraph) Put another way, an overlay, in its current form, exists in order to complement what is on disk, rather than wholesale replace its contents. Therefore I'm unclear that the following expectation is correct:
Indeed it's not possible AFAIU to have an But as I mentioned I think such a "switch" is unnecessary - we can instead add an We should as, part of this change, decide what to do with We could safely make this change today, guarded by build tags - Thoughts on that as a way forward? If so, we would like help implementing this. The only gentle request being that we make this change via Gerrit (because discussion about code, review etc is much easier and more productive). |
This issue has been migrated to cue-lang/cue#607. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Is your feature request related to a problem? Please describe.
I would like to embed a module into the overlay. This would be useful for shipping binaries with the schema embedded, especially with go 1.16 supporting file embeds natively.
This currently does not work due to how the overlay and
cue.mod/module.cue
is handled incue/load/...
Another use case would be loading all inputs from the Overlay. This is useful in a server context where one wants to avoid disk usage. This seems to not work because of how the args to
load.Instances
works. It seems one cannot specify files from the Overlay there.Am I missing a configuration setting?
Describe the solution you'd like
The ability to do the above. Guidance and input on implementation.
Additional context
I've traced the first use case to some TODOs in the code. The first is here: https://github.com/cuelang/cue/blob/master/cue/load/config.go#L498
The processing in this area generates absolute paths. The
fileSystem
infs.go
https://github.com/cuelang/cue/blob/master/cue/load/fs.go#L206With Go 1.16, there is a new FS interface, maybe that should be used? If so, maybe that means this feature is delayed until 1.16 is more widely adopted?
Example that is not working as desired or expected:
The text was updated successfully, but these errors were encountered: