Skip to content
This repository has been archived by the owner on Oct 12, 2020. It is now read-only.
/ viper-etcd Public archive

Advanced ETCD remote config provider for viper.

License

Notifications You must be signed in to change notification settings

xdefrag/viper-etcd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Viper Etcd

Build Status codecov Go Report Card

Advanced ETCD remote config provider for Viper. Default remote config needs json on specific key, this one recursively get all nested key-values.

Attention! This remote provider doesn't support SecretKeyring. Crypt that Viper used for encryption is abandoned and doesn't work well with latest GPG versions. BUT you can use custom decoder.

Usage

Instead of requiring Viper's default remote package, initialize RemoteConfig by yourself like this:

import (
        "github.com/xdefrag/viper-etcd/remote"
	"github.com/spf13/viper"
)

func init() {
        viper.RemoteConfig = &remote.Config{
                Username: "user",
                Password: "pass", // etcd credentials if any

                Decoder: &decode{}, // struct with remote.Decoder interface: 
                // type Decoder interface {
                //         Decode(io.Reader) (interface{}, error)
                // }
                // Set your encryption or serialization tool here.
        }
}

And that's it! More details in example.