-
Notifications
You must be signed in to change notification settings - Fork 29
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
Option to mix configuration types #48
Comments
The If you want different behaviour, I think you have broadly two options:
Neither of these workarounds are probably going to be satisfactory, but this is what I mean for the second option: default:
type: postgres
host: xxx
name: yyy
port: 5432
user: user1
pass: pass1
empty:
type: null
host: null
name: null
port: null
user: null
pass: null
postgres:
type: postgres
host: xxx
name: yyy
port: 5432
user: user2
pass: pass2
sqlite_local:
inherits: empty
type: sqlite
path: "~/data/db/test.db" If you can think of a way to get your desired behaviour that also satisfied backward compatibility, please let me know. |
Thanks, Andrie. Below is a configuration that does a lot of what I am looking for. There is a minimal
|
That's sensible. I have one suggestion, though, and that is to make use of environment variables to store your usernames and passwords. Right now it seems you're trying to encode multiple usernames and passwords in a single plain text file. A better pattern would be to use something like this: pg_default:
type: postgres
host: host_xxx
name: !expr Sys.getenv("postgres_user")
port: !expr Sys.getenv("postgres_password") See the vignette at https://rstudio.github.io/config/articles/inheritance.html#using-r-code-inside-the-yaml-file |
Yes, absolutely. Thanks for the suggestion. |
I have a configuration file for database connections, but for different DBs e.g. Postgres and Sqlite. I therefore need different fields.
When I run
config::get
the function appears to merge values from the configurations I am not asking for. Could functionality be added so that separate and unique configurations can be included in one file?E.g. For the following configuration file,
config::get(config = "sqlite_local")
would return only type, path, not type, host, name, port, user, pass, path.Another style option would be to allow configuration types to nest under a particular config type.
e.g.
config::get(config = "postgres")
would return type, host, name, port, user1, pass1config::get(config = "postgres", key = "key1")
would return type, host, name, port, user2, pass2config::get(config = "sqlite_local")
would return type, pathThe text was updated successfully, but these errors were encountered: