Installer: fix they way secret is sent to the port allocator

Change-Id: I483f0560be289b4bcf80cc2d344d497693b1357e
diff --git a/core/installer/app_manager.go b/core/installer/app_manager.go
index 4f864e4..4f01d46 100644
--- a/core/installer/app_manager.go
+++ b/core/installer/app_manager.go
@@ -190,20 +190,20 @@
 			TargetService: p.TargetService,
 			TargetPort:    p.TargetPort,
 		}
-		if err := json.NewEncoder(&buf).Encode(req); err != nil {
-			return err
-		}
 		allocator := ""
 		for n, r := range reservations {
 			if p.SourcePort == r.Port {
 				allocator = allocators[n]
-				req.Secret = reservations[n].Secret
+				req.Secret = r.Secret
 				break
 			}
 		}
 		if allocator == "" {
 			return fmt.Errorf("Could not find allocator for: %d", p.SourcePort)
 		}
+		if err := json.NewEncoder(&buf).Encode(req); err != nil {
+			return err
+		}
 		resp, err := http.Post(allocator, "application/json", &buf)
 		if err != nil {
 			return err