Soft-Serve: ingress with port-forward
Change-Id: I44dcef24276a86902ad5fa7df2de24cc813b37a9
diff --git a/core/port-allocator/main.go b/core/port-allocator/main.go
index 5b557de..ac063da 100644
--- a/core/port-allocator/main.go
+++ b/core/port-allocator/main.go
@@ -11,7 +11,6 @@
"strconv"
"strings"
- "github.com/giolekva/pcloud/core/installer"
"github.com/giolekva/pcloud/core/installer/soft"
"golang.org/x/crypto/ssh"
@@ -36,19 +35,15 @@
if err := c.repo.Pull(); err != nil {
return nil, err
}
- rel, err := c.repo.ReadYaml(c.path)
- if err != nil {
+ ingressRel := map[string]any{}
+ if err := soft.ReadYaml(c.repo, c.path, &ingressRel); err != nil {
return nil, err
}
- ingressRel, ok := rel.(map[string]any)
- if !ok {
- panic("MUST NOT REACH!")
- }
return ingressRel, nil
}
func (c *repoClient) WriteRelease(rel map[string]any, meta string) error {
- if err := c.repo.WriteYaml(c.path, rel); err != nil {
+ if err := soft.WriteYaml(c.repo, c.path, rel); err != nil {
return err
}
return c.repo.CommitAndPush(meta)
@@ -160,12 +155,14 @@
fmt.Printf("%+v\n", req)
ingressRel, err := s.client.ReadRelease()
if err != nil {
+ fmt.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%+v\n", ingressRel)
tcp, udp, err := extractPorts(ingressRel)
if err != nil {
+ fmt.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
@@ -173,11 +170,13 @@
switch req.Protocol {
case "tcp":
if err := addPort(tcp, req); err != nil {
+ fmt.Println(err)
http.Error(w, err.Error(), http.StatusConflict)
return
}
case "udp":
if err := addPort(udp, req); err != nil {
+ fmt.Println(err)
http.Error(w, err.Error(), http.StatusConflict)
return
}
@@ -209,7 +208,7 @@
if err != nil {
return nil, err
}
- return soft.NewRepoIO(repo, signer), nil
+ return soft.NewRepoIO(repo, signer)
}
func main() {