diff --git a/providers/confmap/confmap.go b/providers/confmap/confmap.go index 9c5871a..b6415fc 100644 --- a/providers/confmap/confmap.go +++ b/providers/confmap/confmap.go @@ -26,7 +26,7 @@ func Provider(mp map[string]interface{}, delim string) *Confmap { return &Confmap{mp: cp} } -// ReadBytes is not supported by the env provider. +// ReadBytes is not supported by the confmap provider. func (e *Confmap) ReadBytes() ([]byte, error) { return nil, errors.New("confmap provider does not support this method") } diff --git a/providers/consul/consul.go b/providers/consul/consul.go index 5693b73..e6350df 100644 --- a/providers/consul/consul.go +++ b/providers/consul/consul.go @@ -144,7 +144,7 @@ func (c *Consul) Watch(cb func(event interface{}, err error)) error { return err } - plan.Handler = func(idx uint64, val interface{}) { + plan.Handler = func(_ uint64, val interface{}) { cb(val, nil) } diff --git a/providers/etcd/etcd.go b/providers/etcd/etcd.go index 11a82de..e4c989b 100644 --- a/providers/etcd/etcd.go +++ b/providers/etcd/etcd.go @@ -49,10 +49,12 @@ func Provider(cfg Config) *Etcd { return &Etcd{client: c, cfg: cfg} } +// ReadBytes is not supported by etcd provider. func (e *Etcd) ReadBytes() ([]byte, error) { return nil, errors.New("etcd provider does not support this method") } +// Read returns a nested config map. func (e *Etcd) Read() (map[string]interface{}, error) { ctx, cancel := context.WithTimeout(context.Background(), e.cfg.DialTimeout) defer cancel() diff --git a/providers/posflag/posflag.go b/providers/posflag/posflag.go index d95a4f8..f28e2a3 100644 --- a/providers/posflag/posflag.go +++ b/providers/posflag/posflag.go @@ -6,9 +6,10 @@ package posflag import ( "errors" + "github.com/spf13/pflag" + "github.com/knadh/koanf" "github.com/knadh/koanf/maps" - "github.com/spf13/pflag" ) // Posflag implements a pflag command line provider. @@ -126,7 +127,7 @@ func (p *Posflag) Read() (map[string]interface{}, error) { return maps.Unflatten(mp, p.delim), nil } -// ReadBytes is not supported by the env koanf. +// ReadBytes is not supported by the pflag provider. func (p *Posflag) ReadBytes() ([]byte, error) { return nil, errors.New("pflag provider does not support this method") } diff --git a/providers/rawbytes/rawbytes.go b/providers/rawbytes/rawbytes.go index 96cc0b8..9e02317 100644 --- a/providers/rawbytes/rawbytes.go +++ b/providers/rawbytes/rawbytes.go @@ -20,12 +20,12 @@ func Provider(b []byte) *RawBytes { return r } -// ReadBytes is not supported by the env provider. +// ReadBytes returns the raw bytes for parsing. func (r *RawBytes) ReadBytes() ([]byte, error) { return r.b, nil } -// Read returns the raw bytes for parsing. +// Read is not supported by rawbytes provider. func (r *RawBytes) Read() (map[string]interface{}, error) { - return nil, errors.New("buf provider does not support this method") + return nil, errors.New("rawbytes provider does not support this method") } diff --git a/providers/s3/s3.go b/providers/s3/s3.go index 0088283..13e6343 100644 --- a/providers/s3/s3.go +++ b/providers/s3/s3.go @@ -64,7 +64,7 @@ func (r *S3) ReadBytes() ([]byte, error) { return data, nil } -// Read returns the raw bytes for parsing. +// Read is not supported for s3 provider. func (r *S3) Read() (map[string]interface{}, error) { return nil, errors.New("s3 provider does not support this method") } diff --git a/providers/structs/structs.go b/providers/structs/structs.go index bff92b7..0022083 100644 --- a/providers/structs/structs.go +++ b/providers/structs/structs.go @@ -6,6 +6,7 @@ import ( "errors" "github.com/fatih/structs" + "github.com/knadh/koanf/maps" ) @@ -16,7 +17,7 @@ type Structs struct { delim string } -// Provider returns a provider that takes a takes a struct and a struct tag +// Provider returns a provider that takes a takes a struct and a struct tag // and uses structs to parse and provide it to koanf. func Provider(s interface{}, tag string) *Structs { return &Structs{s: s, tag: tag} diff --git a/providers/vault/vault.go b/providers/vault/vault.go index 6150af7..2307c10 100644 --- a/providers/vault/vault.go +++ b/providers/vault/vault.go @@ -8,6 +8,7 @@ import ( "time" "github.com/hashicorp/vault/api" + "github.com/knadh/koanf/maps" ) @@ -40,6 +41,7 @@ type Vault struct { cfg Config } +// Provider returns a provider that takes a Vault config. func Provider(cfg Config) *Vault { httpClient := &http.Client{Timeout: cfg.Timeout} client, err := api.NewClient(&api.Config{Address: cfg.Address, HttpClient: httpClient}) @@ -51,10 +53,12 @@ func Provider(cfg Config) *Vault { return &Vault{client: client, cfg: cfg} } +// ReadBytes is not supported by the vault provider. func (r *Vault) ReadBytes() ([]byte, error) { return nil, errors.New("vault provider does not support this method") } +// Read fetches the configuration from the source and returns a nested config map. func (r *Vault) Read() (map[string]interface{}, error) { secret, err := r.client.Logical().Read(r.cfg.Path) if err != nil {