From 870fe0fd01b6e84af59b96a8ff968b5cbe617f57 Mon Sep 17 00:00:00 2001 From: Ying Li Date: Mon, 30 Nov 2015 16:57:18 -0800 Subject: [PATCH] Define injected function types for notary-server/main.getTrustService Signed-off-by: Ying Li --- cmd/notary-server/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/notary-server/main.go b/cmd/notary-server/main.go index 2e63203cfc..bb60f1270a 100644 --- a/cmd/notary-server/main.go +++ b/cmd/notary-server/main.go @@ -119,12 +119,13 @@ func getStore(configuration *viper.Viper, allowedBackends []string) ( 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 // to return -func getTrustService(configuration *viper.Viper, - signerFactory func(string, string, *tls.Config) *client.NotarySigner, - healthRegister func(string, func() error, time.Duration)) ( - signed.CryptoService, string, error) { +func getTrustService(configuration *viper.Viper, sFactory signerFactory, + hRegister healthRegister) (signed.CryptoService, string, error) { switch configuration.GetString("trust_service.type") { case "local": @@ -149,14 +150,14 @@ func getTrustService(configuration *viper.Viper, logrus.Info("Using remote signing service") - notarySigner := signerFactory( + notarySigner := sFactory( configuration.GetString("trust_service.hostname"), configuration.GetString("trust_service.port"), clientTLS, ) minute := 1 * time.Minute - healthRegister( + hRegister( "Trust operational", // If the trust service fails, the server is degraded but not // exactly unheatlthy, so always return healthy and just log an