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
diff --git a/core/port-allocator/main.go b/core/port-allocator/main.go
index 861b1dd..48ffd35 100644
--- a/core/port-allocator/main.go
+++ b/core/port-allocator/main.go
@@ -88,7 +88,7 @@
SourcePort int `json:"sourcePort"`
TargetService string `json:"targetService"`
TargetPort int `json:"targetPort"`
- Secret string `json:"secret,omitempty"`
+ Secret string `json:"secret"`
}
func extractAllocateReq(r io.Reader) (allocateReq, error) {
@@ -183,10 +183,6 @@
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
- if req.Secret != "" {
- http.Error(w, "secret missing", http.StatusBadRequest)
- return
- }
s.l.Lock()
defer s.l.Unlock()
ingressRel, err := s.client.ReadRelease()