1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-21 14:29:40 +02:00

error message updates for different file type

This commit is contained in:
ArrisLee 2021-08-31 16:21:23 +12:00
parent b5c59c8982
commit ed500b51c6
2 changed files with 14 additions and 2 deletions

View file

@ -1,6 +1,7 @@
package stacks
import (
"fmt"
"io/ioutil"
"net/http"
"path/filepath"
@ -97,7 +98,12 @@ func (handler *Handler) createKubernetesStackFromFileContent(w http.ResponseWrit
stackFolder := strconv.Itoa(int(stack.ID))
projectPath, err := handler.FileService.StoreStackFileFromBytes(stackFolder, stack.EntryPoint, []byte(payload.StackFileContent))
if err != nil {
return &httperror.HandlerError{StatusCode: http.StatusInternalServerError, Message: "Unable to persist Kubernetes manifest file on disk", Err: err}
fileType := "Manifest"
if stack.IsComposeFormat {
fileType = "Compose"
}
errMsg := fmt.Sprintf("Unable to persist Kubernetes %s file on disk", fileType)
return &httperror.HandlerError{StatusCode: http.StatusInternalServerError, Message: errMsg, Err: err}
}
stack.ProjectPath = projectPath

View file

@ -1,6 +1,7 @@
package stacks
import (
"fmt"
"net/http"
"strconv"
@ -84,7 +85,12 @@ func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.
stackFolder := strconv.Itoa(int(stack.ID))
_, err = handler.FileService.StoreStackFileFromBytes(stackFolder, stack.EntryPoint, []byte(payload.StackFileContent))
if err != nil {
return &httperror.HandlerError{StatusCode: http.StatusInternalServerError, Message: "Unable to persist Kubernetes manifest file on disk", Err: err}
fileType := "Manifest"
if stack.IsComposeFormat {
fileType = "Compose"
}
errMsg := fmt.Sprintf("Unable to persist Kubernetes %s file on disk", fileType)
return &httperror.HandlerError{StatusCode: http.StatusInternalServerError, Message: errMsg, Err: err}
}
return nil