Implement deploy API
[ric-plt/ricdms.git] / pkg / restful / restful.go
index 9b784a1..46a4387 100644 (file)
@@ -27,11 +27,13 @@ import (
        "os"
 
        ch "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/charts"
+       dm "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/deploy"
        ph "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/health"
        po "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/onboard"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/charts"
+       "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/deploy"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/health"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/restapi/operations/onboard"
        "gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/resthooks"
@@ -47,6 +49,7 @@ func NewRestful() *Restful {
                        ph.NewHealthChecker(),
                        po.NewOnboarder(),
                        ch.NewChartmgr(),
+                       dm.NewDeploymentManager(),
                ),
        }
        r.setupHandler()
@@ -97,6 +100,12 @@ func (r *Restful) setupHandler() {
                return resp
        })
 
+       api.DeployPostDeployHandler = deploy.PostDeployHandlerFunc(func(param deploy.PostDeployParams) middleware.Responder {
+               ricdms.Logger.Debug("==> deployment of xApp")
+               resp := r.rh.DownloadAndInstallChart(param.Body.XAppname, param.Body.Version, *param.Body.Namespace)
+               return resp
+       })
+
        api.ApplicationZipProducer = runtime.ProducerFunc(func(w io.Writer, data interface{}) error {
                if zp, ok := data.(io.ReadCloser); ok {
                        defer zp.Close()