cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.07k stars 288 forks source link

cueconfig: load config from fs.FS #2472

Open nxcc opened 1 year ago

nxcc commented 1 year ago

Is your feature request related to a problem? Please describe. In some situations it would be useful to be able to load cue config from an fs.FS instead of the local filesystem.

Describe the solution you'd like A new function, e.g. LoadFS, similar to the existing Load could be added. It would accept an aditional fs.FS parameter which provides the filesystem to load cue config from.

Describe alternatives you've considered I don't see any good alternative how to load from fs.FS.

Additional context I've created a fork (https://github.com/nxcc/cueconfig) with a simple implementation that suits my need. I use it in cuegen. This allows cuegen to load configuration from several remote sources. I'm open for suggestions to improve the code and would be happy to create a pull request in the cueconfig repo. Please let me know what you think.

myitcv commented 1 year ago

I think this is a duplicate of https://github.com/cue-lang/cue/issues/607, but please let me know if you don't think that is the case.

nxcc commented 1 year ago

This feature request is for the github.com/cue-exp/cueconfig package. cueconfig has only one public function Load, and there is no way to Load cue files from an fs.FS. By adding a second function like e.g. LoadFS it would be possible. #607 is about handling this inside cue itself, when it's done, the implementation of LoadFS, or whatever name makes sense to you, could be much simplified. However, I think it's not a duplicate.

myitcv commented 1 year ago

Thanks for clarifying @nxcc. Lots of interest in the io/fs.FS loading, and I read this too quickly.

szabba commented 10 months ago

Would this be considered a good first issue?