mirror of https://github.com/docker/docs.git
Define injected function types for notary-server/main.getTrustService
Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
parent
1dd04d4e5d
commit
870fe0fd01
|
@ -119,12 +119,13 @@ func getStore(configuration *viper.Viper, allowedBackends []string) (
|
||||||
return store, nil
|
return store, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type signerFactory func(hostname, port string, tlsConfig *tls.Config) *client.NotarySigner
|
||||||
|
type healthRegister func(name string, checkFunc func() error, duration time.Duration)
|
||||||
|
|
||||||
// parses the configuration and determines which trust service and key algorithm
|
// parses the configuration and determines which trust service and key algorithm
|
||||||
// to return
|
// to return
|
||||||
func getTrustService(configuration *viper.Viper,
|
func getTrustService(configuration *viper.Viper, sFactory signerFactory,
|
||||||
signerFactory func(string, string, *tls.Config) *client.NotarySigner,
|
hRegister healthRegister) (signed.CryptoService, string, error) {
|
||||||
healthRegister func(string, func() error, time.Duration)) (
|
|
||||||
signed.CryptoService, string, error) {
|
|
||||||
|
|
||||||
switch configuration.GetString("trust_service.type") {
|
switch configuration.GetString("trust_service.type") {
|
||||||
case "local":
|
case "local":
|
||||||
|
@ -149,14 +150,14 @@ func getTrustService(configuration *viper.Viper,
|
||||||
|
|
||||||
logrus.Info("Using remote signing service")
|
logrus.Info("Using remote signing service")
|
||||||
|
|
||||||
notarySigner := signerFactory(
|
notarySigner := sFactory(
|
||||||
configuration.GetString("trust_service.hostname"),
|
configuration.GetString("trust_service.hostname"),
|
||||||
configuration.GetString("trust_service.port"),
|
configuration.GetString("trust_service.port"),
|
||||||
clientTLS,
|
clientTLS,
|
||||||
)
|
)
|
||||||
|
|
||||||
minute := 1 * time.Minute
|
minute := 1 * time.Minute
|
||||||
healthRegister(
|
hRegister(
|
||||||
"Trust operational",
|
"Trust operational",
|
||||||
// If the trust service fails, the server is degraded but not
|
// If the trust service fails, the server is degraded but not
|
||||||
// exactly unheatlthy, so always return healthy and just log an
|
// exactly unheatlthy, so always return healthy and just log an
|
||||||
|
|
Loading…
Reference in New Issue