"bytes"
"encoding/json"
"fmt"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "os"
+ "path/filepath"
+ "strings"
+
"github.com/buger/jsonparser"
"github.com/ghodss/yaml"
"github.com/google/uuid"
"github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
- "io"
- "io/ioutil"
- "net/http"
- "os"
- "path/filepath"
- "strings"
)
// Handler of REST APIs
type HandlerImpl struct {
- logger *logrus.Logger
- dbAdapter *dbAdapter.DbAdapter
+ logger *logrus.Logger
+ dbAdapter *dbAdapter.DbAdapter
}
// Creates handler implementation
respondError(w, http.StatusInternalServerError, "artifact not available in application package")
return
}
- pluginInfo = "helm.plugin" + ":" + os.Getenv("HELM_PLUGIN_PORT")
+ pluginInfo = "helmplugin" + ":" + os.Getenv("HELM_PLUGIN_PORT")
+ impl.logger.Infof("Plugin Info ", pluginInfo)
case "kubernetes":
pkgPath := PackageFolderPath + packageName + PackageArtifactPath + "Kubernetes"
artifact = impl.getDeploymentArtifact(pkgPath, "*.yaml")
impl.logger.Infof("Artifact to deploy:", artifact)
adapter := pluginAdapter.NewPluginAdapter(pluginInfo, impl.logger)
- workloadId, err := adapter.Instantiate(pluginInfo, req.SelectedMECHostInfo.HostID, artifact)
+ workloadId, err, resStatus := adapter.Instantiate(pluginInfo, req.SelectedMECHostInfo.HostID, artifact)
if err != nil {
st, ok := status.FromError(err)
if ok && st.Code() == codes.InvalidArgument {
respondError(w, http.StatusInternalServerError, err.Error())
}
}
- impl.dbAdapter.UpdateAppInstanceInfoInstStatusHostAndWorkloadId(appInstanceId, "INSTANTIATED", req.SelectedMECHostInfo.HostID, workloadId)
- respondJSON(w, http.StatusAccepted, json.NewEncoder(w).Encode(""))
+ if resStatus == "Failure" {
+ respondError(w, http.StatusInternalServerError, err.Error())
+ }
+
+ impl.dbAdapter.UpdateAppInstanceInfoInstStatusHostAndWorkloadId(appInstanceId, "INSTANTIATED", req.SelectedMECHostInfo.HostID, workloadId)
+ respondJSON(w, http.StatusAccepted, json.NewEncoder(w).Encode(workloadId))
}
// Gets deployment artifact
switch appPackageInfo.DeployType {
case "helm":
- pluginInfo = "helm.plugin" + ":" + os.Getenv("HELM_PLUGIN_PORT")
+ pluginInfo = "helmplugin" + ":" + os.Getenv("HELM_PLUGIN_PORT")
case "kubernetes":
pluginInfo = "kubernetes.plugin" + ":" + os.Getenv("KUBERNETES_PLUGIN_PORT")
default:
var pluginInfo string
switch appPackageInfo.DeployType {
case "helm":
- pluginInfo = "helm.plugin" + ":" + os.Getenv("HELM_PLUGIN_PORT")
+ pluginInfo = "helmplugin" + ":" + os.Getenv("HELM_PLUGIN_PORT")
case "kubernetes":
pluginInfo = "kubernetes.plugin" + ":" + os.Getenv("KUBERNETES_PLUGIN_PORT")
default: