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

Loading configs from different file systems #156

Open
sxwebdev opened this issue Jan 27, 2025 · 5 comments
Open

Loading configs from different file systems #156

sxwebdev opened this issue Jan 27, 2025 · 5 comments

Comments

@sxwebdev
Copy link

How to load configs from OS file system and built-in file system at the same time?

@cristaloleg
Copy link
Member

Afair it was done in https://github.com/cristalhq/aconfig/pull/126/files but not well documented. PRs are welcome.

@sxwebdev
Copy link
Author

Afair it was done in https://github.com/cristalhq/aconfig/pull/126/files but not well documented. PRs are welcome.

As far as I understand, we can use either the embed file system or the OS. But is it possible to use both at the same time? For example, I want to embed a configuration file into the binary, and when the application starts, read the configuration from both the embed and the OS file system

@cristaloleg
Copy link
Member

Well, theoretically you can create a loader for fs or OS but that's a hack. Better would be add FileSys fs.FS field to Config and make it work.

However, mixing fs and real OS under one field sounds hacky again. should it be FileSys []fs.FS ? no idea tbh. Do you have something on your mind?

@sxwebdev
Copy link
Author

Well, theoretically you can create a loader for fs or OS but that's a hack. Better would be add FileSys fs.FS field to Config and make it work.

However, mixing fs and real OS under one field sounds hacky again. should it be FileSys []fs.FS ? no idea tbh. Do you have something on your mind?

not yet, thinking about it. what comes to mind breaks the LoaderFor function. it could accept several configs and merge them. but for now this idea doesn't seem optimal

@sxwebdev
Copy link
Author

sxwebdev commented Jan 27, 2025

this idea has a place to be because for different file systems there can be different configs and different loaders. however, they have common parameters, for example, SkipFlags and others. it is not good that they will be duplicated in different configs

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

No branches or pull requests

2 participants