fix(api): use EntryPoint as a reference to overwrite stack Compose file (#1725)
parent
d34b1d5f9d
commit
706490db5e
|
@ -76,14 +76,14 @@ func (service *Service) GetStackProjectPath(stackIdentifier string) string {
|
||||||
|
|
||||||
// StoreStackFileFromString creates a subfolder in the ComposeStorePath and stores a new file using the content from a string.
|
// StoreStackFileFromString creates a subfolder in the ComposeStorePath and stores a new file using the content from a string.
|
||||||
// It returns the path to the folder where the file is stored.
|
// It returns the path to the folder where the file is stored.
|
||||||
func (service *Service) StoreStackFileFromString(stackIdentifier, stackFileContent string) (string, error) {
|
func (service *Service) StoreStackFileFromString(stackIdentifier, fileName, stackFileContent string) (string, error) {
|
||||||
stackStorePath := path.Join(ComposeStorePath, stackIdentifier)
|
stackStorePath := path.Join(ComposeStorePath, stackIdentifier)
|
||||||
err := service.createDirectoryInStoreIfNotExist(stackStorePath)
|
err := service.createDirectoryInStoreIfNotExist(stackStorePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
composeFilePath := path.Join(stackStorePath, ComposeFileDefaultName)
|
composeFilePath := path.Join(stackStorePath, fileName)
|
||||||
data := []byte(stackFileContent)
|
data := []byte(stackFileContent)
|
||||||
r := bytes.NewReader(data)
|
r := bytes.NewReader(data)
|
||||||
|
|
||||||
|
@ -97,14 +97,14 @@ func (service *Service) StoreStackFileFromString(stackIdentifier, stackFileConte
|
||||||
|
|
||||||
// StoreStackFileFromReader creates a subfolder in the ComposeStorePath and stores a new file using the content from an io.Reader.
|
// StoreStackFileFromReader creates a subfolder in the ComposeStorePath and stores a new file using the content from an io.Reader.
|
||||||
// It returns the path to the folder where the file is stored.
|
// It returns the path to the folder where the file is stored.
|
||||||
func (service *Service) StoreStackFileFromReader(stackIdentifier string, r io.Reader) (string, error) {
|
func (service *Service) StoreStackFileFromReader(stackIdentifier, fileName string, r io.Reader) (string, error) {
|
||||||
stackStorePath := path.Join(ComposeStorePath, stackIdentifier)
|
stackStorePath := path.Join(ComposeStorePath, stackIdentifier)
|
||||||
err := service.createDirectoryInStoreIfNotExist(stackStorePath)
|
err := service.createDirectoryInStoreIfNotExist(stackStorePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
composeFilePath := path.Join(stackStorePath, ComposeFileDefaultName)
|
composeFilePath := path.Join(stackStorePath, fileName)
|
||||||
|
|
||||||
err = service.createFileInStore(composeFilePath, r)
|
err = service.createFileInStore(composeFilePath, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -179,7 +179,7 @@ func (handler *StackHandler) handlePostStacksStringMethod(w http.ResponseWriter,
|
||||||
Env: req.Env,
|
Env: req.Env,
|
||||||
}
|
}
|
||||||
|
|
||||||
projectPath, err := handler.FileService.StoreStackFileFromString(string(stack.ID), stackFileContent)
|
projectPath, err := handler.FileService.StoreStackFileFromString(string(stack.ID), stack.EntryPoint, stackFileContent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger)
|
httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger)
|
||||||
return
|
return
|
||||||
|
@ -431,7 +431,7 @@ func (handler *StackHandler) handlePostStacksFileMethod(w http.ResponseWriter, r
|
||||||
Env: env,
|
Env: env,
|
||||||
}
|
}
|
||||||
|
|
||||||
projectPath, err := handler.FileService.StoreStackFileFromReader(string(stack.ID), stackFile)
|
projectPath, err := handler.FileService.StoreStackFileFromReader(string(stack.ID), stack.EntryPoint, stackFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger)
|
httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger)
|
||||||
return
|
return
|
||||||
|
@ -631,7 +631,7 @@ func (handler *StackHandler) handlePutStack(w http.ResponseWriter, r *http.Reque
|
||||||
}
|
}
|
||||||
stack.Env = req.Env
|
stack.Env = req.Env
|
||||||
|
|
||||||
_, err = handler.FileService.StoreStackFileFromString(string(stack.ID), req.StackFileContent)
|
_, err = handler.FileService.StoreStackFileFromString(string(stack.ID), stack.EntryPoint, req.StackFileContent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger)
|
httperror.WriteErrorResponse(w, err, http.StatusInternalServerError, handler.Logger)
|
||||||
return
|
return
|
||||||
|
|
|
@ -369,8 +369,8 @@ type (
|
||||||
DeleteTLSFile(folder string, fileType TLSFileType) error
|
DeleteTLSFile(folder string, fileType TLSFileType) error
|
||||||
DeleteTLSFiles(folder string) error
|
DeleteTLSFiles(folder string) error
|
||||||
GetStackProjectPath(stackIdentifier string) string
|
GetStackProjectPath(stackIdentifier string) string
|
||||||
StoreStackFileFromString(stackIdentifier string, stackFileContent string) (string, error)
|
StoreStackFileFromString(stackIdentifier, fileName, stackFileContent string) (string, error)
|
||||||
StoreStackFileFromReader(stackIdentifier string, r io.Reader) (string, error)
|
StoreStackFileFromReader(stackIdentifier, fileName string, r io.Reader) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GitService represents a service for managing Git.
|
// GitService represents a service for managing Git.
|
||||||
|
|
Loading…
Reference in New Issue