Skip to content

Structured configuration support (path/dots) #82

Description

@kravemir

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 = "info@mysite.com"
notifications.bcc = "notifications-bcc@mysite.com"

smtp.serveraddr = "smtp.gmail.com:587"
smtp.username = "info@mysite.com"
smtp.password = "secret"
smtp.defaultfrom = "contact@mysite.com"

Or, with YAML:

notifications:
  - enabled: true
  - from: "info@mysite.com"
  - bcc:  "notifications-bcc@mysite.com"

smtp:
  - serveraddr: "smtp.gmail.com:587"
  - username: "info@mysite.com"
  - password: "secret"
  - defaultfrom: "contact@mysite.com"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions