Skip to content
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

Add support for io/fs to load.Instances #814

Closed
cueckoo opened this issue Jul 3, 2021 · 2 comments
Closed

Add support for io/fs to load.Instances #814

cueckoo opened this issue Jul 3, 2021 · 2 comments
Labels
FeatureRequest New feature or request

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @sdboyer in cuelang/cue#814

Is your feature request related to a problem? Please describe.
I have a set of CUE files that i'd like to have available for use with CUE's Go API inside a larger program. These files are knowable at compile time, and i'd like to use Go 1.16 new embed and io/fs to make them available within the program. However, i can't take advantage of load.Instances() with embedded files.

Describe the solution you'd like

The simplest thing i can imagine is:

package load

type Config {
    ...
    // DirFS represents the root of a hierarchical filesystem in which to run the
    // the build system's query tool that provides information about the packages.
    // It is an error to specify both Dir and DirFS.
    // If neither Dir nor DirFS are specified, the tool is run in the current directory.
    DirFS fs.ReadDirFS
}

i don't yet know the new io/fs package well enough to know exactly which composition of the fs interfaces would be sufficient for CUE's needs here. I'm also sure that the above simplistic formulation wouldn't work well if the provided FS is below the module root, so some relation between the above and Config.ModuleRoot probably needs to exist.

Describe alternatives you've considered
It's hard to imagine anything simpler here that allows use of io/fs. I could imagine something more elaborate that ends up as part of an approach to querying, but i can't think of a reason why that would be a reason not to support this simpler case.

@cueckoo cueckoo added the FeatureRequest New feature or request label Jul 3, 2021
@cueckoo cueckoo closed this as completed Jul 3, 2021
@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @verdverm in cuelang/cue#814 (comment)

related: cuelang/cue#607

Cue wants to align with the supported Go versions, i.e. since Go still supports 1.15 Cue does not want to force Go 1.16 on its users. io/fs is definitely a possibility down the road.

You can use io/fs in your own program, walk the filetree, and add them to load.Config.Overlay.

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @sdboyer in cuelang/cue#814 (comment)

Oh, nice! i'd missed Overlay. That'll do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant