Move the passphraseRetriever to its own file.

Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
HuKeping 2016-04-12 11:38:09 +08:00
parent dc147d12c4
commit a80c539ce8
2 changed files with 14 additions and 13 deletions

View File

@ -1,3 +1,16 @@
package main
import ()
import (
"errors"
"strings"
)
func passphraseRetriever(keyName, alias string, createNew bool, attempts int) (passphrase string, giveup bool, err error) {
passphrase = mainViper.GetString(strings.ToUpper(alias))
if passphrase == "" {
return "", false, errors.New("expected env variable to not be empty: " + alias)
}
return passphrase, false, nil
}

View File

@ -2,7 +2,6 @@ package main
import (
"crypto/tls"
"errors"
_ "expvar"
"flag"
"fmt"
@ -10,7 +9,6 @@ import (
"net"
"net/http"
"os"
"strings"
"time"
"google.golang.org/grpc"
@ -66,16 +64,6 @@ func init() {
}
}
func passphraseRetriever(keyName, alias string, createNew bool, attempts int) (passphrase string, giveup bool, err error) {
passphrase = mainViper.GetString(strings.ToUpper(alias))
if passphrase == "" {
return "", false, errors.New("expected env variable to not be empty: " + alias)
}
return passphrase, false, nil
}
// Reads the configuration file for storage setup, and sets up the cryptoservice
// mapping
func setUpCryptoservices(configuration *viper.Viper, allowedBackends []string) (