veyron/services/identity: Remove dependence on rt.R().
Change-Id: I00897a07232fe2d38ac4c908145b1f23ebf730ca
diff --git a/services/identity/identityd/main.go b/services/identity/identityd/main.go
index 5e9f3dc..ccce46f 100644
--- a/services/identity/identityd/main.go
+++ b/services/identity/identityd/main.go
@@ -76,8 +76,11 @@
}
p, blessingLogReader := providerPrincipal(sqlDB)
- r := rt.Init(options.RuntimePrincipal{p})
- defer r.Cleanup()
+ runtime, err := rt.New(options.RuntimePrincipal{p})
+ if err != nil {
+ vlog.Fatal(err)
+ }
+ defer runtime.Cleanup()
var revocationManager *revocation.RevocationManager
// Only set revocationManager sqlConfig (and thus sqlDB) is set.
@@ -89,13 +92,13 @@
}
// Setup handlers
- http.Handle("/pubkey/", handlers.PublicKey{r.Principal().PublicKey()}) // public key of this server
+ http.Handle("/pubkey/", handlers.PublicKey{runtime.Principal().PublicKey()}) // public key of this server
macaroonKey := make([]byte, 32)
if _, err := rand.Read(macaroonKey); err != nil {
vlog.Fatalf("macaroonKey generation failed: %v", err)
}
// Google OAuth
- ipcServer, published, err := setupServices(r, revocationManager, macaroonKey)
+ ipcServer, published, err := setupServices(runtime, revocationManager, macaroonKey)
if err != nil {
vlog.Fatalf("Failed to setup veyron services for blessing: %v", err)
}
@@ -103,7 +106,7 @@
if clientID, clientSecret, ok := getOAuthClientIDAndSecret(*googleConfigWeb); ok {
n := "/google/"
h, err := googleoauth.NewHandler(googleoauth.HandlerArgs{
- R: r,
+ R: runtime,
MacaroonKey: macaroonKey,
Addr: fmt.Sprintf("%s%s", httpaddress(), n),
ClientID: clientID,
@@ -124,7 +127,7 @@
GoogleServers, DischargeServers []string
ListBlessingsRoute string
}{
- Self: rt.R().Principal().BlessingStore().Default(),
+ Self: runtime.Principal().BlessingStore().Default(),
RandomWeb: enableRandomHandler(),
}
if revocationManager != nil {
@@ -142,7 +145,7 @@
})
vlog.Infof("Running HTTP server at: %v", httpaddress())
go runHTTPSServer(*httpaddr)
- <-signals.ShutdownOnSignals(r)
+ <-signals.ShutdownOnSignals(runtime)
}
func appendSuffixTo(objectname []string, suffix string) []string {
diff --git a/services/identity/revocation/revocation_test.go b/services/identity/revocation/revocation_test.go
index 171d036..bb251fe 100644
--- a/services/identity/revocation/revocation_test.go
+++ b/services/identity/revocation/revocation_test.go
@@ -46,8 +46,7 @@
return &RevocationManager{}
}
-func revokerSetup(t *testing.T) (dischargerKey security.PublicKey, dischargerEndpoint string, revoker *RevocationManager, closeFunc func(), runtime veyron2.Runtime) {
- r := rt.Init()
+func revokerSetup(t *testing.T, r veyron2.Runtime) (dischargerKey security.PublicKey, dischargerEndpoint string, revoker *RevocationManager, closeFunc func(), runtime veyron2.Runtime) {
revokerService := newRevocationManager(t)
dischargerServer, err := r.NewServer()
if err != nil {
@@ -71,7 +70,13 @@
}
func TestDischargeRevokeDischargeRevokeDischarge(t *testing.T) {
- dcKey, dc, revoker, closeFunc, r := revokerSetup(t)
+ r, err := rt.New()
+ if err != nil {
+ t.Fatalf("Could not initialize runtime: %v", err)
+ }
+ defer r.Cleanup()
+
+ dcKey, dc, revoker, closeFunc, r := revokerSetup(t, r)
defer closeFunc()
discharger := services.DischargerClient(dc)