1
0
mirror of https://github.com/docker/docs.git synced 2026-11-05 00:14:17 +03:00

Add rethink init for signer config

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
This commit is contained in:
Riyaz Faizullabhoy
2016-03-23 11:18:44 -07:00
parent b8c62731a6
commit f8a67f8af0
2 changed files with 26 additions and 2 deletions

View File

@@ -82,6 +82,29 @@ func setUpCryptoservices(configuration *viper.Viper, allowedBackends []string) (
case notary.MemoryBackend:
keyStore = trustmanager.NewKeyMemoryStore(
passphrase.ConstantRetriever("memory-db-ignore"))
case notary.RethinkDBBackend:
var sess *gorethink.Session
storeConfig, err := utils.ParseRethinkDBStorage(configuration)
if err != nil {
return nil, err
}
sess, err = rethinkdb.Connection(storeConfig.CA, storeConfig.Source, storeConfig.AuthKey)
if err == nil {
defaultAlias := configuration.GetString("storage.default_alias")
if defaultAlias == "" {
// backwards compatibility - support this environment variable
defaultAlias = configuration.GetString(defaultAliasEnv)
}
if defaultAlias == "" {
return nil, fmt.Errorf("must provide a default alias for the key DB")
}
logrus.Debug("Default Alias: ", defaultAlias)
s, err := keydbstore.NewKeyRethinkDBStore(passphraseRetriever, defaultAlias, sess)
keyStore = s
hRegister("DB operational", s.CheckHealth, time.Second*60)
}
case notary.MySQLBackend, notary.SQLiteBackend:
storeConfig, err := utils.ParseSQLStorage(configuration)
if err != nil {

View File

@@ -46,14 +46,15 @@ func (g RethinkPrivateKey) DatabaseName() string {
}
// NewKeyRethinkDBStore returns a new KeyRethinkDBStore backed by a RethinkDB database
func NewKeyRethinkDBStore(passphraseRetriever passphrase.Retriever, defaultPassAlias string, rethinkSession *gorethink.Session) (*KeyRethinkDBStore, error) {
func NewKeyRethinkDBStore(passphraseRetriever passphrase.Retriever, defaultPassAlias string, rethinkSession *gorethink.Session) *KeyRethinkDBStore {
cachedKeys := make(map[string]data.PrivateKey)
return &KeyRethinkDBStore{
session: rethinkSession,
defaultPassAlias: defaultPassAlias,
retriever: passphraseRetriever,
cachedKeys: cachedKeys}, nil
cachedKeys: cachedKeys,
}
}
// Name returns a user friendly name for the storage location