Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emitter-io/config
Configuration management package designed for Emitter.
https://github.com/emitter-io/config
configuration configuration-file emitter golang
Last synced: 3 months ago
JSON representation
Configuration management package designed for Emitter.
- Host: GitHub
- URL: https://github.com/emitter-io/config
- Owner: emitter-io
- License: mit
- Created: 2017-09-03T04:13:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T00:46:57.000Z (almost 2 years ago)
- Last Synced: 2024-06-20T00:28:56.893Z (8 months ago)
- Topics: configuration, configuration-file, emitter, golang
- Language: Go
- Size: 445 KB
- Stars: 7
- Watchers: 4
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# config
This repository contains the configuration parsing and management package designed for Emitter (https://emitter.io) service and related services. The configuration contains a flexible and multi-level secret overrides with `Environment Variable` and `Hashicorp Vault` providers implemented out of the box.
## Installation
If you want to use this package, you can simply `go get` it as shown below.
```
go get github.com/emitter-io/config
```## Usage
```
import (
cfg "github.com/emitter-io/config"
)// NewDefault creates a default configuration.
func NewDefault() cfg.Config {
return &Config{
ListenAddr: ":8080",
Cluster: &ClusterConfig{
ListenAddr: ":4000",
AdvertiseAddr: "public:4000",
Passphrase: "emitter-io",
},
}
}// Config represents main configuration.
type Config struct {
ListenAddr string `json:"listen"` // The API port used for TCP & Websocket communication.'
License string `json:"license"` // The port used for gossip.'
TLS *cfg.TLSConfig `json:"tls,omitempty"` // The API port used for Secure TCP & Websocket communication.'
Secrets *cfg.VaultConfig `json:"vault,omitempty"` // The configuration for the Hashicorp Vault.
Storage *cfg.ProviderConfig `json:"storage,omitempty"` // The configuration for the storage provider.
Contract *cfg.ProviderConfig `json:"contract,omitempty"` // The configuration for the contract provider.
}// Vault returns a vault configuration.
func (c *Config) Vault() *cfg.VaultConfig {
return c.Secrets
}func main() {
// Parse the configuration
cfg, err := config.ReadOrCreate("emitter", "config.json", NewDefault, config.NewEnvironmentProvider(), config.NewVaultProvider("app"))
if err != nil {
panic("Unable to parse configuration, due to " + err.Error())
}...
}```