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

Structured configuration support (path/dots) #82

Open
kravemir opened this issue Feb 4, 2020 · 0 comments
Open

Structured configuration support (path/dots) #82

kravemir opened this issue Feb 4, 2020 · 0 comments

Comments

@kravemir
Copy link

kravemir commented Feb 4, 2020

Does confita support structured configuration? It would be useful to make configurations more clean/organized/structure, and for configurations of growing/large projects.

I have read the README.md, but there's no example for structure config,... And, I didn't find any TOML/YAML/JSON examples of structured configurations.

I would like to populate the following structure:

type Config struct {
	// notifications configuration
	Notifications struct {
		// turns on user notifications for changes/updates/creations
		Enabled bool
		// from email address of emails
		From string
		// BCC addresses of every notification sent
		BCC []string
	}

	// SMTP server/mail-sending configuration
	SMTP struct {
		// format server:port
		ServerAddr string

		// plain auth credentials
		Username, Password string

		// default email address to sent from
		DefaultFrom string
	}
}

For example, with TOML:

notifications.enabled = true
notifications.from = "[email protected]"
notifications.bcc = "[email protected]"

smtp.serveraddr = "smtp.gmail.com:587"
smtp.username = "[email protected]"
smtp.password = "secret"
smtp.defaultfrom = "[email protected]"

Or, with YAML:

notifications:
  - enabled: true
  - from: "[email protected]"
  - bcc:  "[email protected]"

smtp:
  - serveraddr: "smtp.gmail.com:587"
  - username: "[email protected]"
  - password: "secret"
  - defaultfrom: "[email protected]"
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

1 participant