mirror of https://github.com/portainer/portainer
fix(custom-templates): avoid creation of template if the compose file does not exist EE-1470 (#6011)
fix(custom-templates): avoid creation of template if the compose file does not exist EE-1470pull/6083/head
parent
cc3b1face2
commit
a2886115b8
|
@ -2,6 +2,7 @@ package customtemplates
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -270,6 +271,23 @@ func (handler *Handler) createCustomTemplateFromGitRepository(r *http.Request) (
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entryPath := filesystem.JoinPaths(projectPath, customTemplate.EntryPoint)
|
||||||
|
|
||||||
|
exists, err := handler.FileService.FileExists(entryPath)
|
||||||
|
if err != nil || !exists {
|
||||||
|
if err := handler.FileService.RemoveDirectory(projectPath); err != nil {
|
||||||
|
log.Printf("[WARN] [http,customtemplate,git] [error: %s] [message: unable to remove git repository directory]", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
return nil, errors.New("Invalid Compose file, ensure that the Compose file path is correct")
|
||||||
|
}
|
||||||
|
|
||||||
return customTemplate, nil
|
return customTemplate, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue