installer: call reconciler on app install/update/remove
diff --git a/core/installer/welcome/appmanager.go b/core/installer/welcome/appmanager.go
index 033e1db..be077e0 100644
--- a/core/installer/welcome/appmanager.go
+++ b/core/installer/welcome/appmanager.go
@@ -2,6 +2,7 @@
import (
"bytes"
+ "context"
"embed"
"encoding/json"
"fmt"
@@ -9,13 +10,13 @@
"io/ioutil"
"log"
"net/http"
- // "net/http/httputil"
- // "net/url"
+ "time"
"github.com/Masterminds/sprig/v3"
"github.com/labstack/echo/v4"
"github.com/giolekva/pcloud/core/installer"
+ "github.com/giolekva/pcloud/core/installer/tasks"
)
//go:embed appmanager-tmpl
@@ -28,20 +29,23 @@
var appHtmlTmpl string
type AppManagerServer struct {
- port int
- m *installer.AppManager
- r installer.AppRepository[installer.StoreApp]
+ port int
+ m *installer.AppManager
+ r installer.AppRepository[installer.StoreApp]
+ reconciler tasks.Reconciler
}
func NewAppManagerServer(
port int,
m *installer.AppManager,
r installer.AppRepository[installer.StoreApp],
+ reconciler tasks.Reconciler,
) *AppManagerServer {
return &AppManagerServer{
port,
m,
r,
+ reconciler,
}
}
@@ -237,6 +241,8 @@
log.Printf("%s\n", err.Error())
return err
}
+ ctx, _ := context.WithTimeout(context.Background(), 2*time.Minute)
+ go s.reconciler.Reconcile(ctx)
return c.String(http.StatusOK, "Installed")
}
@@ -261,6 +267,8 @@
if err := s.m.Update(a.App, slug, values); err != nil {
return err
}
+ ctx, _ := context.WithTimeout(context.Background(), 2*time.Minute)
+ go s.reconciler.Reconcile(ctx)
return c.String(http.StatusOK, "Installed")
}
@@ -269,6 +277,8 @@
if err := s.m.Remove(slug); err != nil {
return err
}
+ ctx, _ := context.WithTimeout(context.Background(), 2*time.Minute)
+ go s.reconciler.Reconcile(ctx)
return c.String(http.StatusOK, "Installed")
}